Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  1. OpenComputers

    1. Announcements

      OpenComputers official announcements.

      128
      posts
    2. Feedback

      Tell us what you think.

      416
      posts
    3. IRC

      #OC channel discussion
      irc.esper.net #oc

      25
      posts
  2. Code Central

    1. Support

      Ask for support from the OpenComputers community

      4.4k
      posts
    2. Showcase

      Showcase what you have created for OC. No 'malware' or other junk!

      3.1k
      posts
    3. Tutorials

      Help other users out. Please no 'false tutorials'

      153
      posts
  3. Addons & More

    1. Addons Mods

      Show off your OC addons mods

      241
      posts
    2. Architectures

      Discussions for Architectures

      179
      posts
    3. OpenEngineering Task Force

      Discussion board for the OETF documents

      97
      posts
  4. General

    1. Lounge

      Just lounge around or have an open discussion.

      335
      posts
    2. Forum Games

      Fight boredom!

      68
      posts
    3. Showcase

      Show off your creations! (not for your programs)

      145
      posts
    4. Servers

      A place to advertise your servers

      159
      posts
  5. Archives

    1. Public Archives

      OpenComputers public archive forum

      8
      posts
  • Topics

  • Posts

    • Hey based on the program you linked, I made a discord webhook api that should work with OpenOS. But I haven't tested it yet, because I don't have a discord server. So try it and tell me if you run into any issues. First, download a JSON lib: wget https://raw.githubusercontent.com/CptMercury/lunar-json/main/json.lua lunar-json.lua This is the api: --****************************************************************************-- -- # loosly based on HydroNitrogen's Discord webhook api for ComputerCraft -- # See: https://github.com/Wendelstein7/DiscordHook-CC --****************************************************************************-- local checkArg, error = checkArg, error local byte, format = string.byte, string.format --****************************************************************************-- local component = require "component" local inet = require "internet" local ljson = require "lunar-json" --****************************************************************************-- local discord = {} local msg_header = { ["Content-Type"] = "application/x-www-form-urlencoded", ["Source"] = "Minecraft/OpenComputers/Discord" } local json_header = { ["Content-Type"] = "application/json", ["Source"] = "Minecraft/OpenComputers/Discord" } local function escape(s) return s:gsub('[+=&%%%c]', function (c) return format('%%%02X', byte(c)) end) end function discord.createWebhook(url) checkArg(1, url, "string") if not component.isAvailable("internet") then error("Discord Webhook requires an internet card to operate.") end local webhook = { url = url } function webhook.send(msg, username, avatar) checkArg(1, msg, "string") checkArg(2, username, "string", "nil") checkArg(3, avatar, "string", "nil") msg = escape(msg) if username then msg = msg.."&username="..escape(username) end if avatar then msg = msg.."&avatar_url="..escape(avatar) end local res, msg = inet.request(url, msg, msg_header) return res and true or false end function webhook.sendJSON(json) checkArg(1, json, "string") local res, msg = inet.request(url, json, json_header) return res and true or false end function webhook.sendEmbed(msg, title, desc, link, color, img, img_thumb, username, avatar) checkArg(1, msg, "string") checkArg(2, title, "string", "nil") checkArg(3, desc, "string", "nil") checkArg(4, link, "string", "nil") checkArg(5, color, "number", "nil") checkArg(6, img, "string", "nil") checkArg(7, img_thumb, "string", "nil") checkArg(8, username, "string", "nil") checkArg(9, avatar, "string", "nil") local data = { content = msg, username = username, avatar_url = avatar, embeds = { { title = title, description = desc, link = link, color = color } } } if img then data.embeds[1].image = {url = img} end if img_thumb then data.embeds[1].thumbnail = {url = img_thumb} end local success, json = ljson.encode(data, true, false, true, true, true) if not success then error("Unable to encode data as JSON") end local res, msg = inet.request(url, json, json_header) return res and true or false end return webhook end --****************************************************************************-- return discord  
    • Hey, I would also like to have a repository in the Open Programs organization. My nickname: zgyr
    • Hey, here is a function that can glue multiple tables together. It will work for your 2x2 setup, but is more flexible. --# x: number of tables on (horizontal) x-axis (2 in your case) --# y: number of tables on (vertical) y-axis (2 in your case) --# step: number of continuing elements from 1 table (8 in your case) --# ... : the tables you want to merge local function merge(x, y, step, ...) local res = {} for i, tbl in ipairs{...} do local hy = (i - 1) // x local hx = (i - 1) % x for j = 1, #tbl, step do table.move(tbl, j, j+step-1, hy * x * #tbl + hx * step + 1, res) hx = hx + x end end --# if you merge tables in only one specific way, you can move these parameters out of the function --# or hardcode their values local x = 3 local y = 3 local step = 3 local function merge_1(...) local res = {} for i, tbl in ipairs{...} do local hy = (i - 1) // x local hx = (i - 1) % x for j = 1, #tbl, step do table.move(tbl, j, j+step-1, hy *x* #tbl + hx * step + 1, res) hx = hx + x end end return res end return res end This function however requires Lua 5.3 to run (which I would always recommend). If you need Lua 5.2, here's a modified version: local function copy(t1, s, e, j, t2) local c = 0 for i = s, e do t2[j+c] = t1[i] c = c + 1 end end local function merge(x, y, step, ...) local res = {} for i, tbl in ipairs{...} do local hy = math.floor((i - 1) / x) local hx = (i - 1) % x for j = 1, #tbl, step do copy(tbl, j, j+step-1, hy * x * #tbl + hx * step + 1, res) hx = hx + x end end return res end Here's a little test: --[[ Merging 9 tables: 81 80 79 | 78 77 76 | 75 74 73 72 71 70 | 69 68 67 | 66 65 64 63 62 61 | 60 59 58 | 57 56 55 ------------------------------ 54 53 52 | 51 50 49 | 48 47 46 45 44 43 | 42 41 40 | 39 38 37 36 35 34 | 33 32 31 | 30 29 28 ------------------------------ 27 26 25 | 24 23 22 | 21 20 19 18 17 16 | 15 14 13 | 12 11 10 09 08 07 | 06 05 04 / 03 92 01 ]] local t1 = {1, 2, 3, 10, 11, 12, 19, 20, 21} local t2 = {4, 5, 6, 13, 14, 15, 22, 23, 24} local t3 = {7, 8, 9, 16, 17, 18, 25, 26, 27} local t4 = {28, 29, 30, 37, 38, 39, 46, 47, 48} local t5 = {31, 32, 33, 40, 41, 42, 49, 50, 51} local t6 = {34, 35, 36, 43, 44, 45, 52, 53, 54} local t7 = {55, 56, 57, 65, 65, 66, 73, 74, 75} local t8 = {58, 59, 60, 67, 68, 69, 76, 77, 78} local t9 = {61, 62, 63, 70, 71, 72, 79, 80, 81} local res = merge(3, 3, 3, t1, t2, t3, t4, t5, t6, t7, t8, t9) for i, v in ipairs(res) do print(v) end --# This will print numbers 1-81 in order  
    • Well if you want that functionality to be automated you'll need to use a network. Either all the computers that read/write that var broadcast a change to that var over the network while the others listen and update or you have a "server" (single source of truth) that can be signaled to update and publish changes to said var. Does that get your gears moving or should i elaborate?
    • You'll need to take the CPU out of your computer, shift-right click with it in hand to switch it to Lua 5.2 mode and then try again. The bit32 library isn't present in the (now default) Lua 5.3 Archetecture
  • Popular Contributors

    Nobody has received reputation this week.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.