From f57b1642b9b7a0295ee94b39151de6686178376d Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Sat, 12 Feb 2022 16:36:11 -0500 Subject: [PATCH] init --- .luacheckrc | 4 +- computers/api.lua | 3 + computers/demo.lua | 14 ++++ computers/init.lua | 103 +----------------------- computers/{ => old_stuff}/CHANGES.txt | 0 computers/{ => old_stuff}/README.txt | 0 computers/{ => old_stuff}/TODO.txt | 0 computers/{ => old_stuff}/aliases.lua | 0 computers/{ => old_stuff}/computers.lua | 0 computers/{ => old_stuff}/gaming.lua | 0 computers/old_stuff/init.lua | 101 +++++++++++++++++++++++ computers/{ => old_stuff}/recipes.lua | 0 12 files changed, 124 insertions(+), 101 deletions(-) create mode 100644 computers/api.lua create mode 100644 computers/demo.lua rename computers/{ => old_stuff}/CHANGES.txt (100%) rename computers/{ => old_stuff}/README.txt (100%) rename computers/{ => old_stuff}/TODO.txt (100%) rename computers/{ => old_stuff}/aliases.lua (100%) rename computers/{ => old_stuff}/computers.lua (100%) rename computers/{ => old_stuff}/gaming.lua (100%) create mode 100644 computers/old_stuff/init.lua rename computers/{ => old_stuff}/recipes.lua (100%) diff --git a/.luacheckrc b/.luacheckrc index 8ceb8c3..dbe476c 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -7,7 +7,7 @@ globals = { "minetest", "core", --mod provided - "home_vending_machines", + "home_vending_machines", "computers", } read_globals = { @@ -21,5 +21,5 @@ read_globals = { "vector", "ItemStack", "dump", "DIR_DELIM", "VoxelArea", "Settings", "PcgRandom", "VoxelManip", "PseudoRandom", --mod produced - "default", "screwdriver", "unifieddyes", "computers", + "default", "screwdriver", "unifieddyes", } \ No newline at end of file diff --git a/computers/api.lua b/computers/api.lua new file mode 100644 index 0000000..165f2a2 --- /dev/null +++ b/computers/api.lua @@ -0,0 +1,3 @@ +function computers.load_gui(pos, node, clicker) + minetest.chat_send_all("test") +end \ No newline at end of file diff --git a/computers/demo.lua b/computers/demo.lua new file mode 100644 index 0000000..364bff1 --- /dev/null +++ b/computers/demo.lua @@ -0,0 +1,14 @@ +local old_node = minetest.registered_nodes["computers:shefriendSOO"] +old_node.groups.not_in_creative_inventory = 1 +minetest.override_item("computers:shefriendSOO", { + on_rightclick = function(pos, node, clicker, itemstack, pointed_thing) + computers.load_gui(pos, node, clicker) + end, + groups = old_node.groups +}) + +old_node = minetest.registered_nodes["computers:shefriendSOO_off"] +old_node.groups.not_in_creative_inventory = nil +minetest.override_item("computers:shefriendSOO_off", { + groups = old_node.groups +}) \ No newline at end of file diff --git a/computers/init.lua b/computers/init.lua index e3cc6d1..343bfde 100644 --- a/computers/init.lua +++ b/computers/init.lua @@ -1,101 +1,6 @@ computers = {} +computers.modpath = minetest.get_modpath("computers") -computers.register = function (name, def) - if (name:sub(1, 1) == ":") then name = name:sub(2) end - local modname, basename = name:match("^([^:]+):(.*)") - local TEXPFX = modname.."_"..basename.."_" - local ONSTATE = modname..":"..basename - local OFFSTATE = modname..":"..basename.."_off" - local cdef = table.copy(def) - minetest.register_node(ONSTATE, { - drawtype = "nodebox", - paramtype = "light", - paramtype2 = "facedir", - description = cdef.description, - inventory_image = cdef.inventory_image, - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}, - tiles = { - TEXPFX.."tp.png", - TEXPFX.."bt.png", - TEXPFX.."rt.png", - TEXPFX.."lt.png", - TEXPFX.."bk.png", - TEXPFX.."ft.png" - }, - node_box = cdef.node_box, - selection_box = cdef.node_box, - on_rightclick = function (pos, node, clicker, itemstack) - if cdef.on_turn_off and cdef.on_turn_off(pos, node, clicker, itemstack) then - return itemstack - end - node.name = OFFSTATE - minetest.set_node(pos, node) - return itemstack - end - }) - minetest.register_node(OFFSTATE, { - drawtype = "nodebox", - paramtype = "light", - paramtype2 = "facedir", - groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1}, - tiles = { - (TEXPFX.."tp"..(cdef.tiles_off.top and "_off" or "")..".png"), - (TEXPFX.."bt"..(cdef.tiles_off.bottom and "_off" or "")..".png"), - (TEXPFX.."rt"..(cdef.tiles_off.right and "_off" or "")..".png"), - (TEXPFX.."lt"..(cdef.tiles_off.left and "_off" or "")..".png"), - (TEXPFX.."bk"..(cdef.tiles_off.back and "_off" or "")..".png"), - (TEXPFX.."ft"..(cdef.tiles_off.front and "_off" or "")..".png") - }, - node_box = cdef.node_box_off or cdef.node_box, - selection_box = cdef.node_box_off or cdef.node_box, - on_rightclick = function (pos, node, clicker, itemstack) - if cdef.on_turn_on and cdef.on_turn_on(pos, node, clicker, itemstack) then - return itemstack - end - node.name = ONSTATE - minetest.set_node(pos, node) - return itemstack - end, - drop = ONSTATE - }) -end - -computers.register_handheld = function (name, def) - if (name:sub(1, 1) == ":") then name = name:sub(2) end - local modname, basename = name:match("^([^:]+):(.*)") - local TEXPFX = modname.."_"..basename.."_inv" - local ONSTATE = modname..":"..basename - minetest.register_craftitem(ONSTATE, { - description = def.description, - inventory_image = TEXPFX..".png", - wield_image = TEXPFX..".png" - }) -end - -computers.pixelnodebox = function (size, boxes) - local fixed = { } - for _, box in ipairs(boxes) do - local x, y, z, w, h, l = unpack(box) - fixed[#fixed + 1] = { - (x / size) - 0.5, - (y / size) - 0.5, - (z / size) - 0.5, - ((x + w) / size) - 0.5, - ((y + h) / size) - 0.5, - ((z + l) / size) - 0.5 - } - end - return { - type = "fixed", - fixed = fixed - } -end - -local MODPATH = minetest.get_modpath("computers") -dofile(MODPATH.."/computers.lua") -dofile(MODPATH.."/gaming.lua") -dofile(MODPATH.."/aliases.lua") - -if minetest.get_modpath("default") and minetest.get_modpath("basic_materials") then - dofile(MODPATH.."/recipes.lua") -end \ No newline at end of file +dofile(computers.modpath .. "/old_stuff/init.lua") +dofile(computers.modpath .. "/api.lua") +dofile(computers.modpath .. "/demo.lua") diff --git a/computers/CHANGES.txt b/computers/old_stuff/CHANGES.txt similarity index 100% rename from computers/CHANGES.txt rename to computers/old_stuff/CHANGES.txt diff --git a/computers/README.txt b/computers/old_stuff/README.txt similarity index 100% rename from computers/README.txt rename to computers/old_stuff/README.txt diff --git a/computers/TODO.txt b/computers/old_stuff/TODO.txt similarity index 100% rename from computers/TODO.txt rename to computers/old_stuff/TODO.txt diff --git a/computers/aliases.lua b/computers/old_stuff/aliases.lua similarity index 100% rename from computers/aliases.lua rename to computers/old_stuff/aliases.lua diff --git a/computers/computers.lua b/computers/old_stuff/computers.lua similarity index 100% rename from computers/computers.lua rename to computers/old_stuff/computers.lua diff --git a/computers/gaming.lua b/computers/old_stuff/gaming.lua similarity index 100% rename from computers/gaming.lua rename to computers/old_stuff/gaming.lua diff --git a/computers/old_stuff/init.lua b/computers/old_stuff/init.lua new file mode 100644 index 0000000..34947d1 --- /dev/null +++ b/computers/old_stuff/init.lua @@ -0,0 +1,101 @@ +--computers = {} + +computers.register = function (name, def) + if (name:sub(1, 1) == ":") then name = name:sub(2) end + local modname, basename = name:match("^([^:]+):(.*)") + local TEXPFX = modname.."_"..basename.."_" + local ONSTATE = modname..":"..basename + local OFFSTATE = modname..":"..basename.."_off" + local cdef = table.copy(def) + minetest.register_node(ONSTATE, { + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + description = cdef.description, + inventory_image = cdef.inventory_image, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}, + tiles = { + TEXPFX.."tp.png", + TEXPFX.."bt.png", + TEXPFX.."rt.png", + TEXPFX.."lt.png", + TEXPFX.."bk.png", + TEXPFX.."ft.png" + }, + node_box = cdef.node_box, + selection_box = cdef.node_box, + on_rightclick = function (pos, node, clicker, itemstack) + if cdef.on_turn_off and cdef.on_turn_off(pos, node, clicker, itemstack) then + return itemstack + end + node.name = OFFSTATE + minetest.set_node(pos, node) + return itemstack + end + }) + minetest.register_node(OFFSTATE, { + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1}, + tiles = { + (TEXPFX.."tp"..(cdef.tiles_off.top and "_off" or "")..".png"), + (TEXPFX.."bt"..(cdef.tiles_off.bottom and "_off" or "")..".png"), + (TEXPFX.."rt"..(cdef.tiles_off.right and "_off" or "")..".png"), + (TEXPFX.."lt"..(cdef.tiles_off.left and "_off" or "")..".png"), + (TEXPFX.."bk"..(cdef.tiles_off.back and "_off" or "")..".png"), + (TEXPFX.."ft"..(cdef.tiles_off.front and "_off" or "")..".png") + }, + node_box = cdef.node_box_off or cdef.node_box, + selection_box = cdef.node_box_off or cdef.node_box, + on_rightclick = function (pos, node, clicker, itemstack) + if cdef.on_turn_on and cdef.on_turn_on(pos, node, clicker, itemstack) then + return itemstack + end + node.name = ONSTATE + minetest.set_node(pos, node) + return itemstack + end, + drop = ONSTATE + }) +end + +computers.register_handheld = function (name, def) + if (name:sub(1, 1) == ":") then name = name:sub(2) end + local modname, basename = name:match("^([^:]+):(.*)") + local TEXPFX = modname.."_"..basename.."_inv" + local ONSTATE = modname..":"..basename + minetest.register_craftitem(ONSTATE, { + description = def.description, + inventory_image = TEXPFX..".png", + wield_image = TEXPFX..".png" + }) +end + +computers.pixelnodebox = function (size, boxes) + local fixed = { } + for _, box in ipairs(boxes) do + local x, y, z, w, h, l = unpack(box) + fixed[#fixed + 1] = { + (x / size) - 0.5, + (y / size) - 0.5, + (z / size) - 0.5, + ((x + w) / size) - 0.5, + ((y + h) / size) - 0.5, + ((z + l) / size) - 0.5 + } + end + return { + type = "fixed", + fixed = fixed + } +end + +local MODPATH = minetest.get_modpath("computers") .. "/old_stuff" +dofile(MODPATH.."/computers.lua") +dofile(MODPATH.."/gaming.lua") +dofile(MODPATH.."/aliases.lua") + +if minetest.get_modpath("default") and minetest.get_modpath("basic_materials") then + dofile(MODPATH.."/recipes.lua") +end \ No newline at end of file diff --git a/computers/recipes.lua b/computers/old_stuff/recipes.lua similarity index 100% rename from computers/recipes.lua rename to computers/old_stuff/recipes.lua