From 4d8312b79d14e7a9d21055296648faa3731aa364 Mon Sep 17 00:00:00 2001 From: Signal Date: Wed, 22 Oct 2025 18:25:22 -0400 Subject: [PATCH] Add chests, the beginnings of a machines API, and other things --- mods/rgt_base/init.lua | 16 +++ mods/rgt_chests/init.lua | 130 ++++++++++++++++++ mods/rgt_chests/mod.conf | 2 + mods/rgt_chests/models/rgt_chest.gltf | 1 + mods/rgt_chests/textures/rgt_chest.png | Bin 0 -> 984 bytes mods/rgt_cosmetics/wearables.lua | 7 + mods/rgt_inv/init.lua | 95 +++++++++++++ mods/rgt_inv/mod.conf | 2 + mods/rgt_machines/modpack.conf | 0 mods/rgt_machines/rgt_furnace/init.lua | 109 +++++++++++++++ mods/rgt_machines/rgt_furnace/mod.conf | 2 + mods/rgt_machines/rgt_machines_core/init.lua | 27 ++++ mods/rgt_machines/rgt_machines_core/mod.conf | 2 + mods/rgt_materials/init.lua | 19 +++ mods/rgt_player/init.lua | 70 ++++++++-- mods/rgt_tools/init.lua | 19 +++ mods/rgt_towns/rgt_towns_core/plots.lua | 5 + mods/rgt_world/init.lua | 67 ++++++++- mods/rgt_world/textures/rgt_sand.png | Bin 0 -> 339 bytes mods/rgt_world/textures/rgt_stone_brick.png | Bin 0 -> 341 bytes .../textures/rgt_stone_brick_large.png | Bin 0 -> 335 bytes mods/rgt_world/textures/rgt_stone_tile.png | Bin 0 -> 316 bytes 22 files changed, 557 insertions(+), 16 deletions(-) create mode 100644 mods/rgt_chests/init.lua create mode 100644 mods/rgt_chests/mod.conf create mode 100644 mods/rgt_chests/models/rgt_chest.gltf create mode 100644 mods/rgt_chests/textures/rgt_chest.png create mode 100644 mods/rgt_inv/init.lua create mode 100644 mods/rgt_inv/mod.conf create mode 100644 mods/rgt_machines/modpack.conf create mode 100644 mods/rgt_machines/rgt_furnace/init.lua create mode 100644 mods/rgt_machines/rgt_furnace/mod.conf create mode 100644 mods/rgt_machines/rgt_machines_core/init.lua create mode 100644 mods/rgt_machines/rgt_machines_core/mod.conf create mode 100644 mods/rgt_world/textures/rgt_sand.png create mode 100644 mods/rgt_world/textures/rgt_stone_brick.png create mode 100644 mods/rgt_world/textures/rgt_stone_brick_large.png create mode 100644 mods/rgt_world/textures/rgt_stone_tile.png diff --git a/mods/rgt_base/init.lua b/mods/rgt_base/init.lua index 07e5f28..2c990a3 100644 --- a/mods/rgt_base/init.lua +++ b/mods/rgt_base/init.lua @@ -46,6 +46,13 @@ function ns.register_node(name, def) alias = name name = "red_glazed_terracotta:"..name end + if def.groups then + if def.groups.interactable then + def.on_rightclick = function(pos, _, p) + rgt.players[p:get_player_name()].interacting_with = pos + end + end + end if def._variants then if type(def._variants) == "string" then rgt_world["register_"..def._variants](def) @@ -87,6 +94,15 @@ function ns.register_tool(name, def) end end +-- Allow nodes to provide a callback to run on activation without +-- needing to register a bunch of mostly identical LBMs. +minetest.register_lbm { + name = ":red_glazed_terracotta:on_activate", + nodenames = {"group:run_on_activate"}, + action = function(pos, node) + minetest.registered_nodes[node.name].on_activate(pos) + end +} minetest.register_on_joinplayer(function(p) diff --git a/mods/rgt_chests/init.lua b/mods/rgt_chests/init.lua new file mode 100644 index 0000000..d556bf1 --- /dev/null +++ b/mods/rgt_chests/init.lua @@ -0,0 +1,130 @@ +local rgt_chests = { + chests = {} +} +local ns = rgt_chests + +minetest.register_entity(":red_glazed_terracotta:chest_display", { + initial_properties = { + visual = "mesh", + mesh = "rgt_chest.gltf", + textures = {"rgt_chest.png"}, + pointable = false, +-- static_save = false + }, + on_activate = function(e, data) + if not minetest.get_node(e.object:get_pos()).name:find "chest" then + e.object:remove() + return + end + e.object:set_armor_groups{immortal = 1} + e._pos = minetest.deserialize(data) + ns.chests[vector.to_string(e._pos)] = e + e.users = {} + end, + on_deactivate = function(e) + ns.chests[vector.to_string(e._pos)] = nil + end, + get_staticdata = function(e) + return minetest.serialize(e._pos) + end +}) + + +local function make_chest_entity(pos, rot) + local e = minetest.add_entity(pos, "red_glazed_terracotta:chest_display", minetest.serialize(pos)) + e:set_rotation(rot) + return e +end + +-- This node is a hack to allow for a pretty wielditem while having an airlike drawtype on the actual underlying node. +rgt.register_node("chest", { + drawtype = "mesh", + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "4dir", + mesh = "rgt_chest.gltf", + tiles = {"rgt_chest.png"}, + on_place = function(s, p, pt) + return minetest.item_place_node(ItemStack("real_chest"), p, pt) + end +}) + +rgt.register_node("real_chest", { + drawtype = "airlike", + paramtype = "light", + sunlight_propagates = true, + paramtype2 = "4dir", + selection_box = { + type = "fixed", + fixed = { + -7/16, -0.5, -7/16, + 7/16, 6/16, 7/16 + } + }, + groups = { + dig_immediate = 3, + }, + drop = "chest", + on_construct = function(pos) + make_chest_entity(pos, minetest.fourdir_to_dir(minetest.get_node(pos).param2):dir_to_rotation()) + local m = minetest.get_meta(pos) + local inv = m:get_inventory() + inv:set_size("inv", 8*3) + local fs = {"\ + formspec_version[10]\ + size[12,11]\ + style_type[button,image_button;border=false]\ + "} + for x = 0, 7 do + for y = 0, 2 do + fs[#fs +1] = "\ + image["..(x *1.25 +1.125 -0.0625)..","..(y *1.25 +1 -0.0625)..";1.14,1.14;rgt_other_button_bg.png;8,8]\ + " + end + end + for x = 0, 7 do + for y = 0, 3 do + fs[#fs +1] = "\ + image["..(x *1.25 +1.125 -0.0625)..","..(y *1.25 +5.5 -0.0625)..";1.14,1.14;rgt_other_button_bg.png;8,8]\ + " + end + end + fs[#fs +1] = "\ + list[context;inv;1.125,1;8,3;]\ + list[current_player;main;1.125,5.5;8,4;]\ + listring[]\ + " + m:set_string("formspec", table.concat(fs)) + end, + on_destruct = function(pos) + local e = ns.chests[pos:to_string()] + local m = minetest.get_meta(pos) + local inv = m:get_inventory() + for i = 1, inv:get_size("inv") do + local item = minetest.add_item(pos, inv:get_stack("inv", i)) + if item then + item:set_velocity(vector.random_direction() *math.random(1, 3)) + end + end + e.object:remove() + end, + on_rightclick = function(pos, node, p, s, pt) + local e = ns.chests[pos:to_string()] + if not e.open then + e.open = true + e.object:set_animation({x=0,y=0.5}, 1, 0.1, false) + end + e.users[p:get_player_name()] = true + end, + on_receive_fields = function(pos, _, data, p) + local e = ns.chests[pos:to_string()] + if data.quit then + e.users[p:get_player_name()] = nil + if not next(e.users) then + e.open = false + e.object:set_animation({x=0.5,y=1}, 1, 0.1, false) + end + end + end +}) + diff --git a/mods/rgt_chests/mod.conf b/mods/rgt_chests/mod.conf new file mode 100644 index 0000000..74e4c46 --- /dev/null +++ b/mods/rgt_chests/mod.conf @@ -0,0 +1,2 @@ +name = rgt_chests +depends = rgt_base \ No newline at end of file diff --git a/mods/rgt_chests/models/rgt_chest.gltf b/mods/rgt_chests/models/rgt_chest.gltf new file mode 100644 index 0000000..2fcc340 --- /dev/null +++ b/mods/rgt_chests/models/rgt_chest.gltf @@ -0,0 +1 @@ +{"asset":{"version":"2.0","generator":"Blockbench 4.12.5 glTF exporter"},"scenes":[{"nodes":[6],"name":"blockbench_export"}],"scene":0,"nodes":[{"name":"cube","mesh":0},{"name":"body","children":[0]},{"translation":[0,-5.625,-4.0625],"name":"cube","mesh":1},{"translation":[0,-5.625,-4.0625],"name":"cube","mesh":2},{"translation":[0,5.625,4.0625],"name":"lid","children":[2,3]},{"rotation":[0,-1,0,6.123233995736766e-17],"translation":[0,-5,0],"name":"rootr","children":[1,4]},{"children":[5]}],"bufferViews":[{"buffer":0,"byteOffset":0,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":288,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":576,"byteLength":192,"target":34962,"byteStride":8},{"buffer":0,"byteOffset":768,"byteLength":72,"target":34963},{"buffer":0,"byteOffset":840,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":1128,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":1416,"byteLength":192,"target":34962,"byteStride":8},{"buffer":0,"byteOffset":1608,"byteLength":72,"target":34963},{"buffer":0,"byteOffset":1680,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":1968,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":2256,"byteLength":192,"target":34962,"byteStride":8},{"buffer":0,"byteOffset":2448,"byteLength":72,"target":34963},{"buffer":0,"byteOffset":2520,"byteLength":4},{"buffer":0,"byteOffset":2524,"byteLength":16},{"buffer":0,"byteOffset":2540,"byteLength":64},{"buffer":0,"byteOffset":2604,"byteLength":256},{"buffer":0,"byteOffset":2860,"byteLength":4},{"buffer":0,"byteOffset":2864,"byteLength":12}],"buffers":[{"byteLength":2876,"uri":"data:application/octet-stream;base64,AACMQAAAtEAAAIxAAACMQAAAtEAAAIzAAACMQAAAAAAAAIxAAACMQAAAAAAAAIzAAACMwAAAtEAAAIzAAACMwAAAtEAAAIxAAACMwAAAAAAAAIzAAACMwAAAAAAAAIxAAACMwAAAtEAAAIzAAACMQAAAtEAAAIzAAACMwAAAtEAAAIxAAACMQAAAtEAAAIxAAACMwAAAAAAAAIxAAACMQAAAAAAAAIxAAACMwAAAAAAAAIzAAACMQAAAAAAAAIzAAACMwAAAtEAAAIxAAACMQAAAtEAAAIxAAACMwAAAAAAAAIxAAACMQAAAAAAAAIxAAACMQAAAtEAAAIzAAACMwAAAtEAAAIzAAACMQAAAAAAAAIzAAACMwAAAAAAAAIzAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAI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AAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AACAPQAAFD8AAKA9AAAUPwAAgD0AACQ/AACgPQAAJD8AAKA9AAAUPwAAwD0AABQ/AACgPQAAJD8AAMA9AAAkPwAAAD4AABg/AADAPQAAGD8AAAA+AAAUPwAAwD0AABQ/AAAgPgAAFD8AAAA+AAAUPwAAID4AABg/AAAAPgAAGD8AAAA9AAAUPwAAgD0AABQ/AAAAPQAAJD8AAIA9AAAkPwAAAAAAABQ/AAAAPQAAFD8AAAAAAAAkPwAAAD0AACQ/AAACAAEAAgADAAEABAAGAAUABgAHAAUACAAKAAkACgALAAkADAAOAA0ADgAPAA0AEAASABEAEgATABEAFAAWABUAFgAXABUAAAAAAAAAAAAAAAAAAAAAAAAAgD8AAAAAq6oqPauqqj0AAAA+VVVVPlVVlT6rqqo+AADAPlVV1T4AAAA/VVUVP6uqKj8AAEA/VVVVP6uqaj8AAIA/AAAAAAAAAAAAAAAAAACAPwBZHD0AAAAAAAAAAD3Qfz+lbg8+AAAAAAAAAADqeX0/xZeBPgAAAAAAAAAA+Kl3P+EU1T4AAAAAAAAAAODGaD8NkAE/AAAAAAAAAAD8ylw/ho8IPwAAAAAAAAAA1YhYP7ZrDT8AAAAAAAAAAF5kVT+ZkBA/AAAAAAAAAABURlM/6NUSPwAAAAAAAAAA87NRP+KWED8AAAAAAAAAAAdCUz8z1wk/AAAAAAAAAADSuFc/Lu32PgAAAAAAAAAAuEJgP+Y+vj4AAAAAAAAAANqrbT+Rbz4+AAAAAAAAAAC5iHs/AAAAAAAAAAAAAAAAAACAPwAAAAAAAAAAAAC0QAAAgkA="}],"accessors":[{"bufferView":0,"componentType":5126,"count":24,"max":[4.375,5.625,4.375],"min":[-4.375,0,-4.375],"type":"VEC3"},{"bufferView":1,"componentType":5126,"count":24,"max":[1,1,1],"min":[-1,-1,-1],"type":"VEC3"},{"bufferView":2,"componentType":5126,"count":24,"max":[0.65625,0.578125],"min":[0,0],"type":"VEC2"},{"bufferView":3,"componentType":5123,"count":36,"max":[23],"min":[0],"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":24,"max":[4.375,8.75,4.375],"min":[-4.375,5.625,-4.375],"type":"VEC3"},{"bufferView":5,"componentType":5126,"count":24,"max":[1,1,1],"min":[-1,-1,-1],"type":"VEC3"},{"bufferView":6,"componentType":5126,"count":24,"max":[0.65625,0.59375],"min":[0.21875,0],"type":"VEC2"},{"bufferView":7,"componentType":5123,"count":36,"max":[23],"min":[0],"type":"SCALAR"},{"bufferView":8,"componentType":5126,"count":24,"max":[0.625,6.875,-4.375],"min":[-0.625,4.375,-5],"type":"VEC3"},{"bufferView":9,"componentType":5126,"count":24,"max":[1,1,1],"min":[-1,-1,-1],"type":"VEC3"},{"bufferView":10,"componentType":5126,"count":24,"max":[0.15625,0.640625],"min":[0,0.578125],"type":"VEC2"},{"bufferView":11,"componentType":5123,"count":36,"max":[23],"min":[0],"type":"SCALAR"},{"bufferView":12,"componentType":5126,"count":1,"max":[0],"min":[0],"type":"SCALAR"},{"bufferView":13,"componentType":5126,"count":1,"max":[0,0,0,1],"min":[0,0,0,1],"type":"VEC4"},{"bufferView":14,"componentType":5126,"count":16,"max":[1],"min":[0],"type":"SCALAR"},{"bufferView":15,"componentType":5126,"count":16,"max":[0.5735764503479004,0,0,1],"min":[0,0,0,0.8191520571708679],"type":"VEC4"},{"bufferView":16,"componentType":5126,"count":1,"max":[0],"min":[0],"type":"SCALAR"},{"bufferView":17,"componentType":5126,"count":1,"max":[0,5.625,4.0625],"min":[0,5.625,4.0625],"type":"VEC3"}],"materials":[{"pbrMetallicRoughness":{"metallicFactor":0,"roughnessFactor":1,"baseColorTexture":{"index":0}},"alphaMode":"MASK","alphaCutoff":0.05,"doubleSided":true}],"textures":[{"sampler":0,"source":0,"name":"texture"}],"samplers":[{"magFilter":9728,"minFilter":9728,"wrapS":33071,"wrapT":33071}],"images":[{"mimeType":"image/png","name":"rgt_chest.png","uri":"rgt_chest.png"}],"meshes":[{"primitives":[{"mode":4,"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"primitives":[{"mode":4,"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]},{"primitives":[{"mode":4,"attributes":{"POSITION":8,"NORMAL":9,"TEXCOORD_0":10},"indices":11,"material":0}]}],"animations":[{"name":"animation","samplers":[{"input":12,"output":13,"interpolation":"LINEAR"},{"input":14,"output":15,"interpolation":"LINEAR"},{"input":16,"output":17,"interpolation":"LINEAR"}],"channels":[{"sampler":0,"target":{"node":1,"path":"rotation"}},{"sampler":1,"target":{"node":4,"path":"rotation"}},{"sampler":2,"target":{"node":4,"path":"translation"}}]}]} \ No newline at end of file diff --git a/mods/rgt_chests/textures/rgt_chest.png b/mods/rgt_chests/textures/rgt_chest.png new file mode 100644 index 0000000000000000000000000000000000000000..07599438f5bdb3f1494c65f05c03577c7ca5405f GIT binary patch literal 984 zcmV;}11J26P)Px&l1W5CRCt{2n$K?HFc8K+AR!HCd)Na<)R)*p-vDV3eThBrdixan8mk_ASgDmt z2qCZs7&9^c7h?n3^-rpl#Gb}+Wb4^cNee0(-S+25NA zGCcNUK0HE*Ai3vhp#22V)+aXJ6Hw&Cjw`!}A&J>tB|<*4Om7cIF*CV+hfQlupa`B2 zMNNe0fHFK+xR~i4SQa=wak@ULV2<^AqUP9-yl!jv%9P)~8 zBE+@es@0%aqLKzF6GD`9iIgt!x&|E)B&aIT3gYTAH@#aClr1|ql=(zi3-Q6O>QSU)zY@@+adH6##m(EzW)FK%;$3e!0YR4r^9?c$80vkVzCJF zk(^03gm2i9{liNF)-8L?V$$Boc{4B9Tb^Q~U*2VuHRF85FSq0000 11 and 10.5 or -1 + fs[#fs +1] = "image_button["..(i %11 +0.125)..","..y..";0.75,0.75;rgt_stone.png;blah;]" + i = i +1 + end + fs[#fs +1] = "\ + list[current_player;main;1.125,4.5;8,4;]\ + list[current_player;craft;3,0.5;3,3;]\ + listring[]\ + list[current_player;craftpreview;7,1;1,1;]\ + " + e.player:set_inventory_formspec(table.concat(fs)) + end, + on_action = function(e, data) + + end +}, { + __call = function(_, ...) + return Inventory.new(...) + end +}) + +local last_time = 0 +minetest.register_globalstep(function() + local time = minetest.get_us_time() + -- Scan for machines every second. + if time -last_time > 1000000 then + for name, m in pairs(rgt.players) do + local pm = {} + local machines = minetest.find_nodes_in_area(m.pos:offset(-7, -7, -7), m.pos:offset(7, 7, 7), "group:rgt_machine", true) + for type, positions in pairs(machines) do + pm[#pm +1] = { + type = type, + pos = positions[math.random(1, #positions)] + } + end + if not (#pm <= 0 and #m.inv.state.proximate_machines <= 0) then + -- Give the machines list a predictable order by sorting it alphabetically prior to submission. + table.sort(pm, function(a, b) return a.type < b.type end) + m.inv.proximate_machines = pm + end + end + last_time = time + end +end) + + +minetest.register_chatcommand("/lua", { + privs = {server = true}, + func = function(name, args) + xpcall(function() + loadstring(args)() + end, say) + end +}) diff --git a/mods/rgt_inv/mod.conf b/mods/rgt_inv/mod.conf new file mode 100644 index 0000000..55d0839 --- /dev/null +++ b/mods/rgt_inv/mod.conf @@ -0,0 +1,2 @@ +name = rgt_inv +depends = rgt_player \ No newline at end of file diff --git a/mods/rgt_machines/modpack.conf b/mods/rgt_machines/modpack.conf new file mode 100644 index 0000000..e69de29 diff --git a/mods/rgt_machines/rgt_furnace/init.lua b/mods/rgt_machines/rgt_furnace/init.lua new file mode 100644 index 0000000..049639a --- /dev/null +++ b/mods/rgt_machines/rgt_furnace/init.lua @@ -0,0 +1,109 @@ + +local function update_formspec(pos) + +end + +local function on_input(pos, m, inv) + +end + +local function on_add_fuel(pos, m, inv) + +end + +local function destination_list(s) + return minetest.get_item_group(s:get_name(), "furnace_fuel") > 0 and "fuel" or "input" +end + +local function can_run(pos, m, inv) + return false +end + +rgt_machines.register_machine("fuel_furnace", { + states = { + idle = { + tiles = {"rgt_stone.png"}, + }, + active = { + tiles = {"rgt_stone.png"}, + } + }, + on_construct = function(pos) + local m = minetest.get_meta(pos) + local inv = m:get_inventory() + inv:set_size("input", 1) + inv:set_size("output", 1) + -- Dummy list handle Shift-adding properly. + inv:set_size("sort", 1) + inv:set_size("fuel", 1) + + + end, + get_gui = function(pos) + local loc = "nodemeta:"..pos.x..","..pos.y..","..pos.z + local fs = "\ + formspec_version[10]\ + size[12,12]\ + \ + image["..(2 -0.0625)..","..(2 -0.0625)..";1.14,1.14;rgt_other_button_bg.png;8,8]\ + list["..loc..";input;2,2;1,1;]\ + \ + image["..(5 -0.0625)..","..(3 -0.0625)..";1.14,1.14;rgt_other_button_bg.png;8,8]\ + list["..loc..";output;5,3;1,1;]\ + \ + image["..(2 -0.0625)..","..(4 -0.0625)..";1.14,1.14;rgt_other_button_bg.png;8,8]\ + list["..loc..";fuel;2,4;1,1;]\ + " + for x = 0, 7 do + for y = 0, 3 do + fs = fs.."\ + image["..(x *1.25 +1.125 -0.0625)..","..(y *1.25 +6.5 -0.0625)..";1.14,1.14;rgt_other_button_bg.png;8,8]\ + " + end + end + fs = fs.."\ + list[current_player;main;1.125,6.5;8,4;]\ + \ + listring["..loc..";output]\ + listring[current_player;main]\ + listring["..loc..";sort]\ + listring[current_player;main]\ + listring["..loc..";input]\ + listring[current_player;main]\ + listring["..loc..";fuel]\ + listring[current_player;main]\ + " + end, + allow_metadata_inventory_put = function(pos, list, idx, s, p) + local inv = minetest.get_meta(pos):get_inventory() + if list == "output" then + return 0 + elseif list == "input" then + return s:get_count() + elseif list == "fuel" then + return minetest.get_item_group(s:get_name(), "furnace_fuel") > 0 and s:get_count() or 0 + elseif list == "sort" then + local dst = destination_list(s) + if dst then + -- Add everything if we can. + if inv:room_for_item(dst, s) then + return s:get_count() + -- If not, and the stacks are compatible, add as much as possible. + elseif inv:room_for_item(dst, s:take_item()) then + return s:get_stack_max() -inv:get_stack(dst, 1):get_count() + end + end + return 0 + end + return 0 + end, + on_metadata_inventory_put = function(pos, list, idx, s, p) + if list == "sort" then + local inv = minetest.get_meta(pos):get_inventory() + local dst = destination_list(s) + inv:add_item(dst, s) + -- Ensure the sorter list never has anything in it. + inv:set_stack("sort", 1, ItemStack("")) + end + end +}) diff --git a/mods/rgt_machines/rgt_furnace/mod.conf b/mods/rgt_machines/rgt_furnace/mod.conf new file mode 100644 index 0000000..16e295e --- /dev/null +++ b/mods/rgt_machines/rgt_furnace/mod.conf @@ -0,0 +1,2 @@ +name = rgt_furnace +depends = rgt_machines_core \ No newline at end of file diff --git a/mods/rgt_machines/rgt_machines_core/init.lua b/mods/rgt_machines/rgt_machines_core/init.lua new file mode 100644 index 0000000..1e63311 --- /dev/null +++ b/mods/rgt_machines/rgt_machines_core/init.lua @@ -0,0 +1,27 @@ +rgt_machines = { + registered_machines = {} +} +local ns = rgt_machines + +-- This abstracts away the use of multiple nodes for visual state feedback by +-- copying all node callbacks into each node, so that by default the machine +-- behaves exactly the same regardless of the underlying node type. +--[[ + { + states = { ... }, -- Alternate visual states for this node. All properties of the resultant node may be overriden. + ... + } +--]] +function ns.register_machine(name, def) + if not def.groups then + def.groups = {} + end + def.groups.rgt_machine = 1 + def.groups.run_on_activate = 1 + def.groups[name] = 1 + ns.registered_machines[name] = def + for state, x in pairs(def.states) do + rgt.register_node(name.."_"..state, extend(table.copy(def), x)) + end +end + diff --git a/mods/rgt_machines/rgt_machines_core/mod.conf b/mods/rgt_machines/rgt_machines_core/mod.conf new file mode 100644 index 0000000..50eaa76 --- /dev/null +++ b/mods/rgt_machines/rgt_machines_core/mod.conf @@ -0,0 +1,2 @@ +name = rgt_machines_core +depends = rgt_world, rgt_player \ No newline at end of file diff --git a/mods/rgt_materials/init.lua b/mods/rgt_materials/init.lua index 95c3c80..5163185 100644 --- a/mods/rgt_materials/init.lua +++ b/mods/rgt_materials/init.lua @@ -1,10 +1,29 @@ +--[[ + Minimum features needed to make this a playable game: + - Basic towns + - Covered wagon + - Machines + - + - Materials + - Diamond + - Biomes + - Ocean + - Decoration nodes + - Stone bricks + - Stone tile (default stone block) + - Sand + - Gravel +--]] + rgt.register_item("iron_ingot", { inventory_image = "rgt_iron_ingot.png", + groups = {furnace_fuel = 1} }) rgt.register_item("iron_lump", { inventory_image = "rgt_iron_lump.png", + groups = {furnace_smeltable = 1} }) rgt.register_node("iron_block", { diff --git a/mods/rgt_player/init.lua b/mods/rgt_player/init.lua index e5db75e..8458607 100644 --- a/mods/rgt_player/init.lua +++ b/mods/rgt_player/init.lua @@ -45,19 +45,21 @@ Player = { e.wearing = {} + e.logical_height_offset = 0 e:update_hp(p:get_hp()) - e:update_inv() - - return e - end, - update_inv = function(m) - m.object:set_formspec_prepend [[ + e.object:set_formspec_prepend [[ bgcolor[#000;true] background9[0,0;0,0;rgt_container_bg.png;true;16,16] style_type[button;border=false;bgimg=rgt_button_bg.png;bgimg_middle=8,8] listcolors[#fff0;#fff3;#0000;#444;#aaa] ]] + + e.inv = Inventory(p) + + return e + end, + update_inv = function(m) local fs = "\ formspec_version[10]\ size[12,10]\ @@ -65,23 +67,27 @@ Player = { for x = 0, 7 do for y = 0, 3 do fs = fs.."\ - image["..(x *1.25 +1 -0.0625)..","..(y *1.25 +4.5 -0.0625)..";1.14,1.14;rgt_other_button_bg.png;8,8]\ + image["..(x *1.25 +1.125 -0.0625)..","..(y *1.25 +4.5 -0.0625)..";1.14,1.14;rgt_other_button_bg.png;8,8]\ " end end fs = fs.."\ - list[current_player;main;1,4.5;8,4;]\ + list[current_player;main;1.125,4.5;8,4;]\ list[current_player;craft;3,0.5;3,3;]\ listring[]\ list[current_player;craftpreview;7,1;1,1;]\ " m.object:set_inventory_formspec(fs) end, + set_logical_height_offset = function(m, offset) + m.logical_height_offset = offset + m.health_display:set_attach(m.object, nil, vector.new(0, 22 +m.logical_height_offset, 0)) + end, update_hp = function(m, hp) if not (m.health_display and m.health_display:is_valid()) then local pos = m.object:get_pos() or vector.zero() m.health_display = minetest.add_entity(pos, "rgt_player:health_display") - m.health_display:set_attach(m.object, nil, vector.new(0, 22, 0)) + m.health_display:set_attach(m.object, nil, vector.new(0, 22 +m.logical_height_offset, 0)) m.health_display:get_luaentity().owner = m end local tx = "[combine:90x90" @@ -117,7 +123,7 @@ Player = { if def._wield_pos then pos = pos +def._wield_pos end - local rot = def._wield_rot or def.type == "node" and vector.new(45, 40, 30) or (def.type == "tool" and vector.new(90, -45, 90) or vector.new(-90, -100, 90)) + local rot = def._wield_rot or def.type == "node" and vector.new(-45, 165, -30) or (def.type == "tool" and vector.new(90, -45, 90) or vector.new(-90, -100, 90)) local scale = def._wield_scale or vector.new(0.2, 0.2, 0.2) if type(scale) == "number" then @@ -292,8 +298,7 @@ Player = { m.last_time = time end - -- Custom on-hover effects - + -- Run on-hover callbacks m.pointed_node = nil local pointed_found = false @@ -321,6 +326,7 @@ Player = { end end elseif pointed and pointed.type == "node" and not m.pointed_node then + pointed.node_under = minetest.get_node(pointed.under) m.pointed_node = pointed end end @@ -331,9 +337,47 @@ Player = { m.pointed_obj = nil m.hover_trigger_range = nil end - + m.pos = pos + -- Hold-to-interact handling + if m.interacting_with and m.ctl.place then + if not m.interaction_start then + m.interaction_start = time + m.interaction_marker = minetest.add_entity(m.pointed_node.under, "display") + m.interaction_marker:set_properties { + visual = "sprite", + textures = {"rgt_interact_progress_0.png"} + } + else + if time -m.interaction_start > 1100000 then + m.interaction_marker:remove() + minetest.registered_nodes[minetest.get_node(m.interacting_with).name].on_interact(m.interacting_with, m) + elseif time -m.interaction_start > 1000000 then + m.interaction_marker:set_properties { + textures = {"rgt_interact_progress_100.png"} + } + elseif time -m.interaction_start > 750000 then + m.interaction_marker:set_properties { + textures = {"rgt_interact_progress_75.png"} + } + elseif time -m.interaction_start > 500000 then + m.interaction_marker:set_properties { + textures = {"rgt_interact_progress_50.png"} + } + elseif time -m.interaction_start > 250000 then + m.interaction_marker:set_properties { + textures = {"rgt_interact_progress_25.png"} + } + end + end + elseif m.interacting_with and not m.ctl.place then + m.interacting_with = nil + m.interaction_start = nil + m.interaction_marker:remove() + m.interaction_marker = nil + end + -- Run on_wield callbacks local w = p:get_wielded_item() local wname = w:get_name() diff --git a/mods/rgt_tools/init.lua b/mods/rgt_tools/init.lua index eca30e2..96e26c3 100644 --- a/mods/rgt_tools/init.lua +++ b/mods/rgt_tools/init.lua @@ -1,3 +1,22 @@ +--[[ +============== Progression ============= + +* Dig grass to get grass +* Craft grass into (grass) string +* Dig leaves to get sticks +* Craft sticks and (grass) string to get a staff +* Dig loose cobble to get loose cobble +* Craft loose cobble with a staff and (grass) string to get an adze +* Dig a tree with an adze to get a plank (and a surprise) +* Craft a plank with an adze and (grass) string to get a wooden pick head (and one less adze) +* Craft the pick head with a staff and string to get a wooden pick +* Use a wooden pick to dig stone (note: wooden picks only get cobble from ores) +* Use the stone to make a furnace +* Use the furnace to cook loose ore cobble (requires 4x at a time) +* + +--]] + rgt.register_tool("iron_sword", { inventory_image = "rgt_sword_iron.png", diff --git a/mods/rgt_towns/rgt_towns_core/plots.lua b/mods/rgt_towns/rgt_towns_core/plots.lua index 9ac16d2..b93fe50 100644 --- a/mods/rgt_towns/rgt_towns_core/plots.lua +++ b/mods/rgt_towns/rgt_towns_core/plots.lua @@ -224,6 +224,11 @@ function ns.place_plot(grid, pos, plot, owner, rot) local def = ns.plots[plot] + -- Erase all preexisting node metadata. + for _, pos in ipairs(minetest.find_nodes_with_meta(box.min, box.max)) do + minetest.remove_node(pos) + end + minetest.place_schematic(dst, def.schematic, rot, repl, true, {}) local p, gp, m diff --git a/mods/rgt_world/init.lua b/mods/rgt_world/init.lua index 6f9ad78..925c45d 100644 --- a/mods/rgt_world/init.lua +++ b/mods/rgt_world/init.lua @@ -19,6 +19,24 @@ rgt.register_node("stone", { groups = {stone = 1} }) +rgt.register_node("stone_brick", { + tiles = {{name = "rgt_stone_brick.png", align_style = "world"}}, + _variants = "all", + groups = {stone = 1} +}) + +rgt.register_node("stone_brick_large", { + tiles = {{name = "rgt_stone_brick_large.png", align_style = "world"}}, + _variants = "all", + groups = {stone = 1} +}) + +rgt.register_node("stone_tile", { + tiles = {{name = "rgt_stone_tile.png", align_style = "world"}}, + _variants = "all", + groups = {stone = 1} +}) + rgt.register_node("cobble", { tiles = {"rgt_cobble.png"}, _variants = "all", @@ -57,6 +75,10 @@ rgt.register_node("path_grass", { groups = {dig_immediate = 3} }) +rgt.register_node("sand", { + tiles = {"rgt_sand.png"}, + groups = {dig_immediate = 3} +}) rgt.register_node("oak_log", { @@ -222,9 +244,24 @@ minetest.register_alias("adrift:water", "red_glazed_terracotta:water") -- place_offset_y = 1, --} +rgt.register_node("light", { + tiles = {"[fill:1x1:0,0:#fed"}, + light_source = 14, + paramtype = "light" +}) + +minetest.register_ore { + ore_type = "scatter", + ore = "light", + wherein = "stone", + clust_scarcity = 3 * 3 * 3, + clust_num_ores = 5, + clust_size = 1 +} + minetest.register_biome{ - name = "!", + name = "plains", node_top = "dirt_grass", depth_top = 1, @@ -239,10 +276,34 @@ minetest.register_biome{ node_dungeon_alt = "stone", - y_max = alt_max, - y_min = sealevel, + y_max = 3000, + y_min = 2, vertical_blend = 2, + heat_point = 50, + humidity_point = 50, +} + +minetest.register_biome{ + name = "beach", + + node_top = "sand", + depth_top = 1, + + node_filler = "sand", + depth_filler = 2, + + node_riverbed = "sand", + depth_riverbed = 3, + + node_dungeon = "cobble", + node_dungeon_alt = "stone", + + + y_max = 1, + y_min = -3, + vertical_blend = 1, + heat_point = 50, humidity_point = 50, } \ No newline at end of file diff --git a/mods/rgt_world/textures/rgt_sand.png b/mods/rgt_world/textures/rgt_sand.png new file mode 100644 index 0000000000000000000000000000000000000000..6d4251f2cb9efaaf9c80ff8ee19ea21116dca0fa GIT binary patch literal 339 zcmV-Z0j&OsP)Px$4M{{nR5*=YQoC*hAq@2KQlL3OnSAtpSUw?rO3*bXGP0Cn77J~+-WeOucpg9B zFCQ}z`IvQ0BGNVShloxl`4z{$;a#rFj6WNBT&xwFV?#>fQ@dv29@U&TU&UzT~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