Ores, tools, and wielditems

This commit is contained in:
Signal 2025-10-09 12:26:03 -04:00
parent 889aa531ba
commit 9e63d7fe3a
31 changed files with 268 additions and 12 deletions

View file

@ -61,6 +61,32 @@ function ns.register_node(name, def)
end
end
function ns.register_item(name, def)
def._name = name
local alias
if not name:find(":") then
alias = name
name = "red_glazed_terracotta:"..name
end
minetest.register_craftitem(":"..name, def)
if alias then
minetest.register_alias(alias, name)
end
end
function ns.register_tool(name, def)
def._name = name
local alias
if not name:find(":") then
alias = name
name = "red_glazed_terracotta:"..name
end
minetest.register_tool(":"..name, def)
if alias then
minetest.register_alias(alias, name)
end
end
minetest.register_on_joinplayer(function(p)

View file

@ -0,0 +1,12 @@
minetest.register_entity(":display", {
initial_properties = {
visual = "sprite",
textures = {"blank.png"},
pointable = false,
static_save = false
},
on_activate = function(e)
e.object:set_armor_groups{immortal = 1}
end
})

View file

@ -0,0 +1,2 @@
name = rgt_entities
depends = rgt_base

View file

@ -0,0 +1 @@
{"asset":{"version":"2.0","generator":"Blockbench 4.12.5 glTF exporter"},"scenes":[{"nodes":[2],"name":"blockbench_export"}],"scene":0,"nodes":[{"name":"cube","mesh":0},{"name":"root","children":[0]},{"children":[1]}],"bufferViews":[{"buffer":0,"byteOffset":0,"byteLength":48,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":48,"byteLength":48,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":96,"byteLength":32,"target":34962,"byteStride":8},{"buffer":0,"byteOffset":128,"byteLength":12,"target":34963}],"buffers":[{"byteLength":140,"uri":"data:application/octet-stream;base64,AAAgPwAAAAAAACA/AAAgvwAAAAAAACA/AAAgPwAAAAAAACC/AAAgvwAAAAAAACC/AAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAPgAAAAAAAAAAAAAAAAAAAD4AAAA+AAAAAAAAAD4CAAAAAQACAAEAAwA="}],"accessors":[{"bufferView":0,"componentType":5126,"count":4,"max":[0.625,0,0.625],"min":[-0.625,0,-0.625],"type":"VEC3"},{"bufferView":1,"componentType":5126,"count":4,"max":[0,-1,0],"min":[0,-1,0],"type":"VEC3"},{"bufferView":2,"componentType":5126,"count":4,"max":[0.125,0.125],"min":[0,0],"type":"VEC2"},{"bufferView":3,"componentType":5123,"count":6,"max":[3],"min":[0],"type":"SCALAR"}],"materials":[{"pbrMetallicRoughness":{"metallicFactor":0,"roughnessFactor":1},"alphaMode":"MASK","alphaCutoff":0.05,"doubleSided":true}],"meshes":[{"primitives":[{"mode":4,"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]}]}

View file

@ -0,0 +1 @@
{"asset":{"version":"2.0","generator":"Blockbench 4.12.4 glTF exporter"},"scenes":[{"nodes":[2],"name":"blockbench_export"}],"scene":0,"nodes":[{"name":"cube","mesh":0},{"name":"root","children":[0]},{"children":[1]}],"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}],"buffers":[{"byteLength":840,"uri":"data:application/octet-stream;base64,C9cjOvYoID8L1yM6C9cjOvYoID8AAAAAC9cjOgAAID8L1yM6C9cjOgAAID8AAAAAAAAAAPYoID8AAAAAAAAAAPYoID8L1yM6AAAAAAAAID8AAAAAAAAAAAAAID8L1yM6AAAAAPYoID8AAAAAC9cjOvYoID8AAAAAAAAAAPYoID8L1yM6C9cjOvYoID8L1yM6AAAAAAAAID8L1yM6C9cjOgAAID8L1yM6AAAAAAAAID8AAAAAC9cjOgAAID8AAAAAAAAAAPYoID8L1yM6C9cjOvYoID8L1yM6AAAAAAAAID8L1yM6C9cjOgAAID8L1yM6C9cjOvYoID8AAAAAAAAAAPYoID8AAAAAC9cjOgAAID8AAAAAAAAAAAAAID8AAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAPwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAACAvwAAAAAAAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgD8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAgL8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIA/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAIC/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACAAEAAgADAAEABAAGAAUABgAHAAUACAAKAAkACgALAAkADAAOAA0ADgAPAA0AEAASABEAEgATABEAFAAWABUAFgAXABUA"}],"accessors":[{"bufferView":0,"componentType":5126,"count":24,"max":[0.0006250000442378223,0.6256250143051147,0.0006250000442378223],"min":[0,0.625,0],"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,0],"min":[0,0],"type":"VEC2"},{"bufferView":3,"componentType":5123,"count":36,"max":[23],"min":[0],"type":"SCALAR"}],"materials":[{"pbrMetallicRoughness":{"metallicFactor":0,"roughnessFactor":1},"alphaMode":"MASK","alphaCutoff":0.05,"doubleSided":true}],"meshes":[{"primitives":[{"mode":4,"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]}]}

View file

@ -0,0 +1,79 @@
rgt.register_item("iron_ingot", {
inventory_image = "rgt_iron_ingot.png",
})
rgt.register_item("iron_lump", {
inventory_image = "rgt_iron_lump.png",
})
rgt.register_node("iron_block", {
tiles = {"rgt_iron_block.png"},
groups = {stone = 1}
})
rgt.register_node("iron_ore", {
tiles = {"rgt_stone.png^rgt_iron_ore.png"},
drop = "iron_lump",
groups = {stone = 1}
})
minetest.register_ore {
ore_type = "scatter",
ore = "iron_ore",
wherein = "stone",
clust_scarcity = 4 * 4 * 4,
clust_num_ores = 8,
clust_size = 3,
noise_params = {
offset = 0,
scale = 1,
spread = {x = 100, y = 100, z = 100},
seed = 23,
octaves = 3,
persistence = 0.7
},
}
rgt.register_item("gold_ingot", {
inventory_image = "rgt_gold_ingot.png",
})
rgt.register_item("gold_lump", {
inventory_image = "rgt_gold_lump.png",
})
rgt.register_node("gold_block", {
tiles = {"rgt_gold_block.png"},
groups = {stone = 1}
})
rgt.register_node("gold_ore", {
tiles = {"rgt_stone.png^rgt_gold_ore.png"},
drop = "gold_lump",
groups = {stone = 1}
})
minetest.register_ore {
ore_type = "scatter",
ore = "gold_ore",
wherein = "stone",
clust_scarcity = 4 * 4 * 4,
clust_num_ores = 8,
clust_size = 3,
noise_params = {
offset = 0,
scale = 1,
spread = {x = 100, y = 100, z = 100},
seed = 9858,
octaves = 3,
persistence = 0.7
},
}

View file

@ -0,0 +1,2 @@
name = rgt_materials
depends = rgt_world

Binary file not shown.

After

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 301 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 283 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 302 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 540 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

View file

@ -49,21 +49,22 @@ Player = {
end,
update_hp = function(m, hp)
if not (m.health_display and m.health_display:is_valid()) then
local pos = m.object:get_pos()
if not pos then return end
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:get_luaentity().owner = m
end
local tx = "[combine:90x90"
for i = math.floor(hp /2), math.floor(m.props.hp_max /2) -1 do
tx = tx..":"..(i *9)..",40=rgt_heart_empty.png"
end
for i = 0, math.floor(hp /2) -1 do
tx = tx..":"..(i *9)..",40=rgt_heart.png"
end
if hp %2 ~= 0 then
tx = tx..":"..((math.floor(hp /2)) *9)..",40=rgt_heart.png\\^[fill\\:5x9\\:4,0\\:#000\\^[makealpha\\:#000"
if hp < m.props.hp_max then
for i = math.floor(hp /2), math.floor(m.props.hp_max /2) -1 do
tx = tx..":"..(i *9)..",40=rgt_heart_empty.png"
end
for i = 0, math.floor(hp /2) -1 do
tx = tx..":"..(i *9)..",40=rgt_heart.png"
end
if hp %2 ~= 0 then
tx = tx..":"..((math.floor(hp /2)) *9)..",40=rgt_heart.png\\^[fill\\:5x9\\:4,0\\:#000\\^[makealpha\\:#000"
end
end
m.health_display:set_properties {
visual = "sprite",
@ -71,6 +72,44 @@ Player = {
shaded = false
}
end,
set_wielditem = function(m, def)
if not def then def = {name = ""} end
if not (m.wielditem_display and m.wielditem_display:is_valid()) then
local mp = m.object:get_pos() or vector.zero()
m.wielditem_display = minetest.add_entity(mp, "display")
m.wielditem_display:set_properties {
visual = "item"
}
local e = m.wielditem_display:get_luaentity()
e.owner = m
end
local pos = def.type == "node" and vector.new(0.2, -6, 2) or vector.new(0.2, -5.5, 2.5)
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 scale = def._wield_scale or vector.new(0.2, 0.2, 0.2)
if type(scale) == "number" then
scale = vector.new(scale, scale, scale)
end
if def.name == "air" or def.name == "" or not (def.tiles or def.wield_image or def.inventory_image) then
m.wielditem_display:set_properties {
visual = "sprite",
textures = {"blank.png"}
}
m.wielditem_display:set_attach(m.object, "RightArm", pos, rot)
return
end
m.wielditem_display:set_properties {
visual = "item",
visual_size = scale,
wield_item = def.name
}
m.wielditem_display:set_attach(m.object, "RightArm", pos, rot)
end,
tick = function(m, dtime)
local time = minetest.get_us_time()
local p = m.object
@ -274,6 +313,7 @@ Player = {
if onunselect then onunselect(m) end
end
m.prev_wielditem = wname
m:set_wielditem(def)
local onselect = def and def.on_wield
if onselect then onselect(m, w) end
end
@ -370,3 +410,11 @@ minetest.register_chatcommand("hungerbar", {
end
end
})
minetest.register_chatcommand("wi", {
func = function(name, args)
local m = rgt.players[name]
local x, y, z = args:match "(%-?%d+)%s+(%-?%d+)%s+(%-?%d+)"
m.wielditem_display:set_attach(m.object, "RightArm", vector.new(0.2, -5.5, 2.5), vector.new(tonumber(x), tonumber(y), tonumber(z)))
end
})

View file

@ -1,2 +1,2 @@
name = rgt_player
depends = rgt_base
depends = rgt_entities

83
mods/rgt_tools/init.lua Normal file
View file

@ -0,0 +1,83 @@
rgt.register_tool("iron_sword", {
inventory_image = "rgt_sword_iron.png",
_wield_scale = 0.4,
_wield_pos = vector.new(0, 0, 1)
})
rgt.register_tool("iron_pick", {
inventory_image = "rgt_pick_iron.png",
_wield_scale = 0.4,
_wield_pos = vector.new(0, 0, 1),
tool_capabilities = {
full_punch_interval = 0.9,
max_drop_level = 0,
groupcaps = {
stone = {times = {1, 2, 3}, uses = 100}
}
}
})
rgt.register_tool("iron_axe", {
inventory_image = "rgt_axe_iron.png",
_wield_scale = 0.4,
_wield_pos = vector.new(0, 0, 1),
})
rgt.register_tool("iron_shovel", {
inventory_image = "rgt_shovel_iron.png",
_wield_scale = 0.4,
_wield_pos = vector.new(0, 0, 1)
})
minetest.register_chatcommand("iron", {
func = function(name)
local inv = rgt.players[name].object:get_inventory()
for _, x in ipairs {"lump", "ingot", "block", "sword", "pick", "axe", "shovel"} do
inv:add_item("main", ItemStack("iron_"..x))
end
end
})
rgt.register_tool("gold_sword", {
inventory_image = "rgt_sword_gold.png",
_wield_scale = 0.4,
_wield_pos = vector.new(0, 0, 1)
})
rgt.register_tool("gold_pick", {
inventory_image = "rgt_pick_gold.png",
_wield_scale = 0.4,
_wield_pos = vector.new(0, 0, 1),
tool_capabilities = {
full_punch_interval = 0.9,
max_drop_level = 0,
groupcaps = {
stone = {times = {1, 2, 3}, uses = 100}
}
}
})
rgt.register_tool("gold_axe", {
inventory_image = "rgt_axe_gold.png",
_wield_scale = 0.4,
_wield_pos = vector.new(0, 0, 1),
})
rgt.register_tool("gold_shovel", {
inventory_image = "rgt_shovel_gold.png",
_wield_scale = 0.4,
_wield_pos = vector.new(0, 0, 1)
})
minetest.register_chatcommand("gold", {
func = function(name)
local inv = rgt.players[name].object:get_inventory()
for _, x in ipairs {"lump", "ingot", "block", "sword", "pick", "axe", "shovel"} do
inv:add_item("main", ItemStack("gold_"..x))
end
end
})

2
mods/rgt_tools/mod.conf Normal file
View file

@ -0,0 +1,2 @@
name = rgt_tools
depends = rgt_materials

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 271 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 309 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 348 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 277 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

View file

@ -16,7 +16,7 @@ include "variants.lua"
rgt.register_node("stone", {
tiles = {{name = "rgt_stone.png", align_style = "world"}},
_variants = "all",
groups = {dig_immediate = 3}
groups = {stone = 1}
})
rgt.register_node("cobble", {

Binary file not shown.

After

Width:  |  Height:  |  Size: 362 B