Add copper, and the beginnings of a machine system.
72
mods/rgt_achievements/init.lua
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
local ns = rgt
|
||||
|
||||
local achievements = {}
|
||||
ns.achievements = achievements
|
||||
local root_achievements = {}
|
||||
|
||||
function ns.register_achievement(def)
|
||||
if not def.label then
|
||||
def.label = def.name:gsub("_", " "):gsub("%s%a", function(a) return " "..string.upper(a) end)
|
||||
end
|
||||
if not def.depends then
|
||||
table.insert(root_achievements, def.name)
|
||||
def.depends = {}
|
||||
end
|
||||
achievements[def.name] = def
|
||||
end
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
table.sort(root_achievements)
|
||||
for id, def in pairs(achievements) do
|
||||
for _, dep in ipairs(def.depends) do
|
||||
local d_def = achievements[dep]
|
||||
if not d_def.children then d_def.children = {} end
|
||||
if d_def then
|
||||
table.insert(d_def.children, id)
|
||||
else
|
||||
minetest.log("error", "[rgt_achievements] Missing dependency '"..dep.."' for '"..id.."'")
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
|
||||
|
||||
function ns.show_achievements(name)
|
||||
local fs = [[
|
||||
formspec_version[10]
|
||||
size[12.5,10.5]
|
||||
scroll_container[0.25,0.25;12,11;blah;horizontal;;]
|
||||
scroll_container[0.25,0.25;12,10;blah2;vertical;;]
|
||||
]]
|
||||
|
||||
for i, x in ipairs(root_achievements) do
|
||||
fs = fs.."image[0,"..(i *0.5)..";0.25,0.25;rgt_stone.png]"
|
||||
end
|
||||
|
||||
fs = fs..[[
|
||||
scroll_container_end[]
|
||||
scroll_container_end[]
|
||||
scrollbaroptions[min=0;max=256]
|
||||
scrollbar[0,0;-800,0;horizontal;blah;]
|
||||
scrollbar[0,0;-800,0;vertical;blah2;]
|
||||
]]
|
||||
|
||||
minetest.show_formspec(name, "achievements", fs)
|
||||
end
|
||||
|
||||
|
||||
|
||||
ns.register_achievement {
|
||||
name = "survival",
|
||||
}
|
||||
|
||||
ns.register_achievement {
|
||||
name = "machines",
|
||||
}
|
||||
|
||||
minetest.register_chatcommand("a", {
|
||||
func = function(name)
|
||||
ns.show_achievements(name)
|
||||
end
|
||||
})
|
||||
2
mods/rgt_achievements/mod.conf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_achievements
|
||||
depnds = rgt_ui, rgt_base
|
||||
|
|
@ -36,8 +36,39 @@ function say(msg)
|
|||
minetest.chat_send_all("# Server: "..msg)
|
||||
end
|
||||
|
||||
EventTarget = {
|
||||
init = function()
|
||||
local e = {
|
||||
listeners = {}
|
||||
}
|
||||
return setmetatable(e, {__index = EventTarget})
|
||||
end,
|
||||
listen = function(e, channel, fn)
|
||||
if not e.listeners[channel] then e.listeners[channel] = {} end
|
||||
local l = e.listeners[channel]
|
||||
l[#l +1] = fn
|
||||
end,
|
||||
unlisten = function(e, channel, fn)
|
||||
if not e.listeners[channel] then return end
|
||||
local l = e.listeners[channel]
|
||||
local idx = table.indexof(l, fn)
|
||||
if idx < 0 then return end
|
||||
table.remove(l, idx)
|
||||
end,
|
||||
dispatch = function(e, channel, ...)
|
||||
local l = e.listeners[channel]
|
||||
if not l then return end
|
||||
for i = 1, #l do
|
||||
l[i](...)
|
||||
end
|
||||
end
|
||||
}
|
||||
setmetatable(EventTarget, {
|
||||
__call = function(_, ...) return EventTarget.init(...) end
|
||||
})
|
||||
|
||||
rgt = {
|
||||
horizontal_neighbor_offests = {
|
||||
adjacent_neighbor_offests = {
|
||||
vector.new(0,0,1),
|
||||
vector.new(0,0,-1),
|
||||
vector.new(1,0,0),
|
||||
|
|
@ -52,7 +83,9 @@ rgt = {
|
|||
vector.new(0,0,-1),
|
||||
vector.new(1,0,0),
|
||||
vector.new(-1,0,0),
|
||||
}
|
||||
},
|
||||
nodes_to_content_ids = {},
|
||||
content_ids_to_nodes = {}
|
||||
}
|
||||
local ns = rgt
|
||||
|
||||
|
|
@ -80,6 +113,9 @@ function ns.register_node(name, def)
|
|||
end
|
||||
end
|
||||
minetest.register_node(":"..name, def)
|
||||
local cid = minetest.get_content_id(name)
|
||||
ns.nodes_to_content_ids[name] = cid
|
||||
ns.content_ids_to_nodes[cid] = name
|
||||
if alias then
|
||||
minetest.register_alias(alias, name)
|
||||
end
|
||||
|
|
@ -111,6 +147,26 @@ function ns.register_tool(name, def)
|
|||
end
|
||||
end
|
||||
|
||||
function ns.register_entity(name, def)
|
||||
minetest.register_entity(name, def)
|
||||
end
|
||||
|
||||
-- Out-of-line node metadata, allowing meta for a node to be accessed even when its containing mapblock is not loaded.
|
||||
local db = minetest.get_mod_storage()
|
||||
local NodeMetaRef = {
|
||||
set = function(e, key, value)
|
||||
return db:set_string(e._pos.."_"..key, value)
|
||||
end,
|
||||
get = function(e, key)
|
||||
return db:get(e._pos.."_"..key)
|
||||
end,
|
||||
}
|
||||
NodeMetaRef.__index = NodeMetaRef
|
||||
|
||||
function ns.get_node_meta(pos)
|
||||
return setmetatable({_pos = tostring(minetest.hash_node_position(pos))}, NodeMetaRef)
|
||||
end
|
||||
|
||||
-- Allow nodes to provide a callback to run on activation without
|
||||
-- needing to register a bunch of mostly identical LBMs.
|
||||
minetest.register_lbm {
|
||||
|
|
|
|||
0
mods/rgt_machines/rgt_alloy_furnace/init.lua
Normal file
2
mods/rgt_machines/rgt_alloy_furnace/mod.conf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_alloy_furnace
|
||||
depends = rgt_machines
|
||||
|
|
@ -5,8 +5,9 @@ local function can_work(node, m, inv)
|
|||
if input:get_count() > 0 then
|
||||
-- Would melting this item exceed our fluid capacity?
|
||||
local fluid = m:get_float "fluid"
|
||||
local capacity = m:get_int "fluid_capacity"
|
||||
if capacity -fluid >= 1 then
|
||||
local fluid_type = m:get "fluid_type"
|
||||
local capacity = m:get_float "fluid_capacity"
|
||||
if capacity -fluid >= 1 and (fluid == 0 or input:get_definition().material == fluid_type) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
|
@ -16,7 +17,7 @@ end
|
|||
local function update_formspec(m, progress)
|
||||
progress = progress or m:get_int "progress"
|
||||
local fluid = m:get_float "fluid"
|
||||
local capacity = m:get_int "fluid_capacity"
|
||||
local capacity = m:get_float "fluid_capacity"
|
||||
local progressbar = progress == 0 and "rgt_progress_bg.png^[transformR270" or "rgt_progress_bg.png^[lowpart:"..progress..":rgt_progress_bg_active.png^[transformR270"
|
||||
local fluidcontainer = fluid == 0 and "rgt_fluid_container_bg.png" or "rgt_fluid_container_bg.png^[lowpart:"..(fluid /capacity *100)..":rgt_fluid_container_bg_filled.png"
|
||||
local fs = {"\
|
||||
|
|
@ -57,11 +58,14 @@ local function update(pos, elapsed)
|
|||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
local progress = m:get_int("progress") +20
|
||||
local progress = m:get_int("progress") +50
|
||||
|
||||
if progress >= 100 then
|
||||
local fluid = m:get_float "fluid"
|
||||
fluid = fluid +1
|
||||
if fluid >= 2 then
|
||||
fluid = fluid -rgt_machines.push_fluid(pos, m:get "fluid_type", fluid)
|
||||
end
|
||||
m:set_float("fluid", fluid)
|
||||
|
||||
-- Consume an item.
|
||||
|
|
@ -69,6 +73,8 @@ local function update(pos, elapsed)
|
|||
s:take_item()
|
||||
inv:set_stack("input", 1, s)
|
||||
|
||||
m:set_string("fluid_type", s:get_definition().material)
|
||||
|
||||
progress = 0
|
||||
end
|
||||
m:set_int("progress", progress)
|
||||
|
|
@ -90,7 +96,7 @@ rgt_machines.register_machine("arc_furnace", {
|
|||
},
|
||||
active = {
|
||||
tiles = {"rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_arc_furnace_front_active.png"},
|
||||
drop = "arc_furnace_idle"
|
||||
drop = "arc_furnace_idle",
|
||||
}
|
||||
},
|
||||
paramtype2 = "4dir",
|
||||
|
|
@ -100,7 +106,7 @@ rgt_machines.register_machine("arc_furnace", {
|
|||
local inv = m:get_inventory()
|
||||
inv:set_size("input", 1)
|
||||
|
||||
m:set_int("fluid_capacity", 10)
|
||||
m:set_float("fluid_capacity", 10)
|
||||
m:set_string("active", "false")
|
||||
|
||||
update_formspec(m)
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
name = rgt_arc_furnace
|
||||
depends = rgt_machines_core
|
||||
depends = rgt_machines
|
||||
167
mods/rgt_machines/rgt_casting_basin/init.lua
Normal file
|
|
@ -0,0 +1,167 @@
|
|||
local ns = rgt_machines
|
||||
|
||||
ns.casting_recipes = {
|
||||
{
|
||||
name = "plate",
|
||||
label = "Plate"
|
||||
},
|
||||
{
|
||||
name = "rod",
|
||||
label = "Rod"
|
||||
},
|
||||
{
|
||||
name = "gear",
|
||||
label = "Gear"
|
||||
},
|
||||
}
|
||||
|
||||
local function can_work(node, m, inv)
|
||||
-- Do we have an input item?
|
||||
local fluid = m:get_float "fluid"
|
||||
if m:contains "recipe" and m:contains "fluid_type" and fluid > 0 and inv:get_stack("output", 1):get_free_space() > 0 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function update_formspec(m, progress)
|
||||
progress = progress or m:get_int "progress"
|
||||
local fluid_type = m:get_string "fluid_type"
|
||||
local fluid = m:get_float "fluid"
|
||||
local capacity = m:get_int "fluid_capacity"
|
||||
local progressbar = progress == 0 and "rgt_progress_bg.png^[transformR270" or "rgt_progress_bg.png^[lowpart:"..progress..":rgt_progress_bg_active.png^[transformR270"
|
||||
local fluidcontainer = fluid == 0 and "rgt_fluid_container_bg.png" or "rgt_fluid_container_bg.png^[lowpart:"..(fluid /capacity *100)..":rgt_fluid_container_bg_filled.png"
|
||||
local fs = {"\
|
||||
formspec_version[10]\
|
||||
size[12,12]\
|
||||
image[3.5,2;1,1;", progressbar, "]\
|
||||
image[2,1;1,3;", minetest.formspec_escape(fluidcontainer), "]\
|
||||
label[0.5,0.5;", fluid, " / ", capacity, "]\
|
||||
", ui.list("context", "output", 5, 2, 1, 1), "\
|
||||
"}
|
||||
fs[#fs +1] = ui.list("current_player", "main", 1.125, 6.5, 8, 4)
|
||||
fs[#fs +1] = "\
|
||||
listring[]"
|
||||
|
||||
local recipe = m:get "recipe"
|
||||
|
||||
local x = 0
|
||||
local y = 0
|
||||
for _, r in ipairs(ns.casting_recipes) do
|
||||
if r.name == recipe then
|
||||
fs[#fs +1] = "style[select_recipe_"..r.name..";bgimg=rgt_other_button_bg.png]"
|
||||
end
|
||||
fs[#fs +1] = "image_button["..(x *1.1 +7)..","..(y +1.5)..";1,1;rgt_cast_"..r.name..".png;select_recipe_"..r.name..";]\
|
||||
tooltip[select_recipe_"..r.name..";"..(r.label or r.name).."]\
|
||||
"
|
||||
x = x +1
|
||||
end
|
||||
|
||||
m:set_string("formspec", table.concat(fs))
|
||||
end
|
||||
|
||||
local function activate(pos, node, m)
|
||||
m:set_string("active", "true")
|
||||
node.name = "casting_basin_active"
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
local function deactivate(pos, node, m)
|
||||
m:set_string("active", "false")
|
||||
m:set_int("progress", 0)
|
||||
update_formspec(m)
|
||||
node.name = "casting_basin_idle"
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
local function update(pos, elapsed)
|
||||
local node = minetest.get_node(pos)
|
||||
local m = minetest.get_meta(pos)
|
||||
local inv = m:get_inventory()
|
||||
|
||||
local active = m:get_string("active") == "true"
|
||||
|
||||
if can_work(node, m, inv) then
|
||||
if not active then
|
||||
active = true
|
||||
activate(pos, node, m)
|
||||
end
|
||||
|
||||
local progress = m:get_int("progress") +20
|
||||
|
||||
if progress >= 100 then
|
||||
local fluid = m:get_float "fluid"
|
||||
fluid = fluid -1
|
||||
m:set_float("fluid", fluid)
|
||||
|
||||
local s = inv:get_stack("output", 1)
|
||||
if s and s:get_count() > 0 then
|
||||
s:set_count(s:get_count() +1)
|
||||
else
|
||||
s = ItemStack(m:get_string("fluid_type").."_"..m:get_string("recipe"))
|
||||
end
|
||||
inv:set_stack("output", 1, s)
|
||||
|
||||
progress = 0
|
||||
end
|
||||
m:set_int("progress", progress)
|
||||
|
||||
update_formspec(m, progress)
|
||||
|
||||
elseif active then
|
||||
active = false
|
||||
deactivate(pos, node, m)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
rgt_machines.register_machine("casting_basin", {
|
||||
states = {
|
||||
idle = {
|
||||
tiles = {"rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_casting_basin_front.png"}
|
||||
},
|
||||
active = {
|
||||
tiles = {"rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_casting_basin_front_active.png"},
|
||||
drop = "casting_basin_idle",
|
||||
}
|
||||
},
|
||||
paramtype2 = "4dir",
|
||||
groups = {dig_immediate = 3, fluid_sink = 1},
|
||||
on_construct = function(pos)
|
||||
local m = minetest.get_meta(pos)
|
||||
local inv = m:get_inventory()
|
||||
inv:set_size("output", 1)
|
||||
|
||||
m:set_int("fluid_capacity", 10)
|
||||
m:set_string("active", "false")
|
||||
|
||||
update_formspec(m)
|
||||
|
||||
minetest.get_node_timer(pos):start(1)
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
local m = minetest.get_meta(pos)
|
||||
local inv = m:get_inventory()
|
||||
for i = 1, inv:get_size("input") do
|
||||
local item = minetest.add_item(pos, inv:get_stack("input", i))
|
||||
if item then
|
||||
item:set_velocity(vector.random_direction() *math.random(2, 3))
|
||||
end
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, list, idx, s, p)
|
||||
return 0
|
||||
end,
|
||||
on_receive_fields = function(pos, form, data, p)
|
||||
for k, v in pairs(data) do
|
||||
if k:find "^select_recipe_" then
|
||||
local m = minetest.get_meta(pos)
|
||||
local recipe = k:match "^select_recipe_(.*)"
|
||||
m:set_string("recipe", recipe)
|
||||
update_formspec(m)
|
||||
end
|
||||
end
|
||||
end,
|
||||
on_timer = update
|
||||
})
|
||||
2
mods/rgt_machines/rgt_casting_basin/mod.conf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_casting_basin
|
||||
depends = rgt_machines
|
||||
BIN
mods/rgt_machines/rgt_casting_basin/textures/rgt_cast_gear.png
Normal file
|
After Width: | Height: | Size: 167 B |
BIN
mods/rgt_machines/rgt_casting_basin/textures/rgt_cast_plate.png
Normal file
|
After Width: | Height: | Size: 173 B |
BIN
mods/rgt_machines/rgt_casting_basin/textures/rgt_cast_rod.png
Normal file
|
After Width: | Height: | Size: 107 B |
|
After Width: | Height: | Size: 262 B |
|
After Width: | Height: | Size: 303 B |
|
|
@ -33,7 +33,7 @@ rgt_machines.register_machine("fuel_furnace", {
|
|||
local inv = m:get_inventory()
|
||||
inv:set_size("input", 1)
|
||||
inv:set_size("output", 1)
|
||||
-- Dummy list handle Shift-adding properly.
|
||||
-- Dummy list to handle Shift-adding properly.
|
||||
inv:set_size("sort", 1)
|
||||
inv:set_size("fuel", 1)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
name = rgt_furnace
|
||||
depends = rgt_machines_core
|
||||
depends = rgt_machines
|
||||
38
mods/rgt_machines/rgt_machines/cables.lua
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
local ns = rgt_machines
|
||||
|
||||
local nodebox = {
|
||||
type = "connected",
|
||||
disconnected = {1/8, 1/8, 1/8, -1/8, -1/8, -1/8},
|
||||
connect_top = {1/8, 1/2, 1/8, -1/8, -1/8, -1/8},
|
||||
connect_bottom = {1/8, 1/8, 1/8, -1/8, -1/2, -1/8},
|
||||
connect_front = {1/8, 1/8, 1/8, -1/8, -1/8, -1/2},
|
||||
connect_left = {1/8, 1/8, 1/8, -1/2, -1/8, -1/8},
|
||||
connect_back = {1/8, 1/8, 1/2, -1/8, -1/8, -1/8},
|
||||
connect_right = {1/2, 1/8, 1/8, -1/8, -1/8, -1/8}
|
||||
}
|
||||
|
||||
|
||||
function ns.register_cable(type, def)
|
||||
rgt.register_node("cable_"..type, {
|
||||
drawtype = "nodebox",
|
||||
node_box = nodebox,
|
||||
connects_to = {"group:cable", "group:machine"},
|
||||
tiles = {"rgt_cable_"..type..".png"},
|
||||
groups = {cable = 1, dig_immediate = 3, network_component = 1},
|
||||
paramtype = "light",
|
||||
sunlight_propagates = true,
|
||||
on_construct = function(pos)
|
||||
ns.update_network(pos)
|
||||
end,
|
||||
after_destruct = function(pos)
|
||||
ns.update_network(pos)
|
||||
end,
|
||||
cable_def = def
|
||||
})
|
||||
end
|
||||
|
||||
ns.register_cable("copper", {
|
||||
resistance = 0,
|
||||
max_transference = 200
|
||||
})
|
||||
-- //lua say(dump(minetest.get_meta(rgt.players.singleplayer.pos:round()):to_table()))
|
||||
74
mods/rgt_machines/rgt_machines/fluids.lua
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
local ns = rgt_machines
|
||||
|
||||
-- The recursive funtion that executes a request to push fluid to a network.
|
||||
local function push_fluid(pos, node, ctx)
|
||||
-- Indicate that this node has now been checked.
|
||||
ctx.ignore[minetest.hash_node_position(pos)] = true
|
||||
|
||||
-- If the node is a sink, add as much fluid to it as we can.
|
||||
if minetest.get_item_group(node, "fluid_sink") > 0 then
|
||||
local m = minetest.get_meta(pos)
|
||||
local fluid = m:get_float "fluid"
|
||||
local fluid_type = m:get "fluid_type"
|
||||
local space = m:get_float "fluid_capacity" -fluid
|
||||
|
||||
-- If possible, cast the type of an empty tank to that of the fluid we're pushing; if, however, the tank already contains some amount of a different fluid type, we should not push anything.
|
||||
if ctx.type ~= fluid_type then
|
||||
if not fluid_type or fluid == 0 then
|
||||
m:set_string("fluid_type", ctx.type)
|
||||
else
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- Push as much fluid into the receiver's tank as we can, and decrement the amount awaiting transfer appropriately.
|
||||
if space >= ctx.amount then
|
||||
m:set_float("fluid", fluid +ctx.amount)
|
||||
ctx.amount = 0
|
||||
else
|
||||
m:set_float("fluid", fluid +space)
|
||||
ctx.amount = ctx.amount -space
|
||||
end
|
||||
-- If the node is a pipe, continue pushing to its neighbors.
|
||||
elseif minetest.get_item_group(node, "pipe") > 0 then
|
||||
for _, x in ipairs(rgt.adjacent_neighbor_offests) do
|
||||
-- If we've no fluid left to push, we can just stop.
|
||||
if ctx.amount <= 0 then break end
|
||||
|
||||
if not ctx.ignore[minetest.hash_node_position(pos +x)] then
|
||||
push_fluid(pos +x, node, ctx)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Pushes fluid from `pos` to any connected fluid network.
|
||||
-- Returns the amount of fluid that was successfully pushed.
|
||||
function ns.push_fluid(pos, type, amount)
|
||||
-- Create a master storage table for this push request.
|
||||
local ctx = {
|
||||
ignore = {minetest.hash_node_position(pos)}, -- Nodes we have already checked.
|
||||
type = type, -- The type of the fluid we are sending.
|
||||
amount = amount -- How much fluid remains to be sent.
|
||||
}
|
||||
-- Recursively dispatch the request to all neighbors in sequence.
|
||||
for _, x in ipairs(rgt.adjacent_neighbor_offests) do
|
||||
if ctx.amount > 0 and not ctx.ignore[minetest.hash_node_position(pos +x)] then
|
||||
push_fluid(pos +x, minetest.get_node(pos +x).name, ctx)
|
||||
end
|
||||
end
|
||||
-- Return the amount we were able to transfer (amount requested minus amount left).
|
||||
return amount -ctx.amount
|
||||
end
|
||||
|
||||
-- Pulls fluid into `pos` from any connected fluid network.
|
||||
-- Returns false if no fluid could be pulled, and the amount pulled otherwise.
|
||||
function ns.pull_fluid(pos)
|
||||
|
||||
end
|
||||
|
||||
function ns.register_fluid_tank(name, def)
|
||||
rgt.register_node("fluid_tank_"..name, {
|
||||
|
||||
})
|
||||
end
|
||||
171
mods/rgt_machines/rgt_machines/init.lua
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
--[[
|
||||
List of machines:
|
||||
- Arc furnace: Melts materials into their liquid form
|
||||
--]]
|
||||
|
||||
|
||||
rgt_machines = {
|
||||
registered_machines = {},
|
||||
networks = {}
|
||||
}
|
||||
local ns = rgt_machines
|
||||
|
||||
local db = minetest.get_mod_storage()
|
||||
function ns.get_network(id)
|
||||
return minetest.deserialize(db:get(id) or "return nil") or {supply = 0, demand = 0}
|
||||
end
|
||||
|
||||
-- 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.machine = 1
|
||||
def.groups.network_component = 1
|
||||
def.groups.run_on_activate = 1
|
||||
def.groups[name] = 1
|
||||
|
||||
-- Ensure that we update the network when a machine is placed or removed.
|
||||
local _on_construct = def.on_construct
|
||||
def.on_construct = function(pos)
|
||||
ns.update_network(pos)
|
||||
if _on_construct then _on_construct(pos) end
|
||||
end
|
||||
local _after_destruct = def.after_destruct
|
||||
def.after_destruct = function(pos)
|
||||
ns.update_network(pos)
|
||||
if _after_destruct then _after_destruct(pos) end
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
-- Recursively propagate a network reassignment to all connected nodes (ignoring positions in `ignore`).
|
||||
local function propagate_network_update(pos, net, ignore)
|
||||
ignore[minetest.hash_node_position(pos)] = true
|
||||
-- Store the network to the target node.
|
||||
minetest.get_meta(pos):set_string("network", net)
|
||||
-- Check each neighboring node for further propagation.
|
||||
for _, x in ipairs(rgt.adjacent_neighbor_offests) do
|
||||
-- If we already checked this node, we shouldn't consider it to avoid infinite recursion.
|
||||
if not ignore[minetest.hash_node_position(pos +x)] then
|
||||
local cid = minetest.get_node_raw(pos.x +x.x, pos.y +x.y, pos.z +x.z)
|
||||
-- Ensure that this node can belong to a network and thus is a valid propagation target.
|
||||
if minetest.get_item_group(rgt.content_ids_to_nodes[cid], "network_component") > 0 then
|
||||
propagate_network_update(pos +x, net, ignore)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Called when a pos is added to or removed from a network.
|
||||
-- Whether an addition or deletion is being performed depends on whether the node at `pos` belongs to the `network_component` group.
|
||||
function ns.update_network(pos)
|
||||
-- We're adding a node.
|
||||
if minetest.get_item_group(minetest.get_node(pos).name, "network_component") > 0 then
|
||||
-- Find all adjacent networks.
|
||||
local net
|
||||
local nets = {}
|
||||
local num_nets = 0
|
||||
for _, x in ipairs(rgt.adjacent_neighbor_offests) do
|
||||
-- Ensure that this is a node that should have a network field.
|
||||
if minetest.get_item_group(minetest.get_node(pos +x).name, "network_component") > 0 then
|
||||
local n = minetest.get_meta(pos +x):get("network")
|
||||
-- If the node doesn't have a network for some reason, we should give it one.
|
||||
if not n or table.indexof(nets, n) == -1 then
|
||||
-- Set our network to the first one we find.
|
||||
if not net then
|
||||
net = n
|
||||
-- Store the positions of any other adjacent networks, so we can merge them with ours.
|
||||
elseif net ~= n then
|
||||
nets[#nets +1] = x
|
||||
end
|
||||
num_nets = num_nets +1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Propagate our chosen network to adjacent networks with different IDs.
|
||||
-- If we didn't find any adjacent networks, this will just do nothing.
|
||||
local ignore = {[minetest.hash_node_position(pos)] = true}
|
||||
for _, x in ipairs(nets) do
|
||||
propagate_network_update(pos +x, net, ignore)
|
||||
end
|
||||
|
||||
-- Create a new unique network ID if none of our neighbors have one.
|
||||
if not net then
|
||||
net = string.format("net_%d_%06d", minetest.get_us_time(), math.random(100000, 999999))
|
||||
end
|
||||
|
||||
-- Save our chosen network ID.
|
||||
minetest.get_meta(pos):set_string("network", net)
|
||||
-- We're removing a node.
|
||||
else
|
||||
-- Find all adjacent networks.
|
||||
local net
|
||||
local nets = {}
|
||||
for _, x in ipairs(rgt.adjacent_neighbor_offests) do
|
||||
-- Ensure that this is a node that should have a network field.
|
||||
if minetest.get_item_group(minetest.get_node(pos +x).name, "network_component") > 0 then
|
||||
local n = minetest.get_meta(pos +x):get("network")
|
||||
nets[#nets +1] = x
|
||||
end
|
||||
end
|
||||
-- We only need to ensure that these networks are unique, thus one of them can keep its original ID.
|
||||
if #nets > 1 then table.remove(nets, 1) end
|
||||
|
||||
-- Create a new ID for each network and propagate it.
|
||||
local pos_hash = minetest.hash_node_position(pos)
|
||||
for _, x in ipairs(nets) do
|
||||
net = string.format("net_%d_%06d", minetest.get_us_time(), math.random(100000, 999999))
|
||||
-- Provide a different ignore table each time, to ensure that when the same network abuts this node on multiple edges, all touching nodes get the same network in the end.
|
||||
propagate_network_update(pos +x, net, {[pos_hash] = true})
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
function ns.add_network_supply(id, amount)
|
||||
local net = ns.get_network(id)
|
||||
net.supply = net.supply +amount
|
||||
db:set_string(id, minetest.serialize(net))
|
||||
end
|
||||
|
||||
function ns.remove_network_supply(id, amount)
|
||||
ns.add_network_supply(id, -amount)
|
||||
end
|
||||
|
||||
function ns.change_network_supply(id, from, to)
|
||||
ns.add_network_supply(id, to -from)
|
||||
end
|
||||
|
||||
function ns.add_network_demand(id, amount)
|
||||
local net = ns.get_network(id)
|
||||
net.demand = net.demand +amount
|
||||
db:set_string(id, minetest.serialize(net))
|
||||
end
|
||||
|
||||
function ns.remove_network_demand(id, amount)
|
||||
ns.add_network_demand(id, -amount)
|
||||
end
|
||||
|
||||
function ns.change_network_demand(id, from, to)
|
||||
ns.add_network_demand(id, to -from)
|
||||
end
|
||||
|
||||
include "fluids.lua"
|
||||
|
||||
include "cables.lua"
|
||||
include "pipes.lua"
|
||||
|
||||
2
mods/rgt_machines/rgt_machines/mod.conf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_machines
|
||||
depends = rgt_world, rgt_player
|
||||
|
|
@ -6,7 +6,7 @@ local function update_pipe(pos, leaf)
|
|||
local dir
|
||||
local pipe
|
||||
|
||||
for _, offset in ipairs(rgt.adjacent_horizontal_neighbor_offests) do
|
||||
for _, offset in ipairs(rgt.adjacent_neighbor_offests) do
|
||||
pipe = minetest.get_node(pos +offset)
|
||||
if minetest.get_item_group(pipe.name, "pipe_straight") > 0 then
|
||||
neighbors[#neighbors +1] = offset
|
||||
|
|
@ -48,7 +48,7 @@ rgt.register_node("pipe_straight", {
|
|||
update_pipe(pos)
|
||||
end,
|
||||
after_destruct = function(pos)
|
||||
for _, offset in ipairs(rgt.adjacent_horizontal_neighbor_offests) do
|
||||
for _, offset in ipairs(rgt.adjacent_neighbor_offests) do
|
||||
pipe = minetest.get_node(pos +offset)
|
||||
if minetest.get_item_group(pipe.name, "pipe_straight") > 0 then
|
||||
update_pipe(pos +offset, true)
|
||||
|
|
@ -70,7 +70,7 @@ rgt.register_node("pipe_straight_single_cap", {
|
|||
update_pipe(pos)
|
||||
end,
|
||||
after_destruct = function(pos)
|
||||
for _, offset in ipairs(rgt.adjacent_horizontal_neighbor_offests) do
|
||||
for _, offset in ipairs(rgt.adjacent_neighbor_offests) do
|
||||
pipe = minetest.get_node(pos +offset)
|
||||
if minetest.get_item_group(pipe.name, "pipe_straight") > 0 then
|
||||
update_pipe(pos +offset, true)
|
||||
|
|
@ -92,7 +92,7 @@ rgt.register_node("pipe_straight_double_cap", {
|
|||
update_pipe(pos)
|
||||
end,
|
||||
after_destruct = function(pos)
|
||||
for _, offset in ipairs(rgt.adjacent_horizontal_neighbor_offests) do
|
||||
for _, offset in ipairs(rgt.adjacent_neighbor_offests) do
|
||||
pipe = minetest.get_node(pos +offset)
|
||||
if minetest.get_item_group(pipe.name, "pipe_straight") > 0 then
|
||||
update_pipe(pos +offset, true)
|
||||
BIN
mods/rgt_machines/rgt_machines/textures/rgt_cable_copper.png
Normal file
|
After Width: | Height: | Size: 231 B |
|
Before Width: | Height: | Size: 183 B After Width: | Height: | Size: 183 B |
|
Before Width: | Height: | Size: 204 B After Width: | Height: | Size: 204 B |
|
Before Width: | Height: | Size: 896 B After Width: | Height: | Size: 896 B |
|
Before Width: | Height: | Size: 176 B After Width: | Height: | Size: 176 B |
|
Before Width: | Height: | Size: 187 B After Width: | Height: | Size: 187 B |
|
|
@ -1,11 +0,0 @@
|
|||
local ns = rgt_machines
|
||||
|
||||
function ns.create_fluid_tank(m)
|
||||
|
||||
end
|
||||
|
||||
function ns.make_fluid_display(x, y, fliud, max, amount)
|
||||
local fs = {}
|
||||
|
||||
return table.concat(fs)
|
||||
end
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
--[[
|
||||
List of machines:
|
||||
- Arc furnace: Melts materials into their liquid form
|
||||
--]]
|
||||
|
||||
|
||||
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
|
||||
|
||||
include "fluids.lua"
|
||||
|
||||
include "pipes.lua"
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
name = rgt_machines_core
|
||||
depends = rgt_world, rgt_player
|
||||
132
mods/rgt_machines/rgt_steam_generator/init.lua
Normal file
|
|
@ -0,0 +1,132 @@
|
|||
|
||||
local function can_work(node, m, inv)
|
||||
-- Do we have an input item?
|
||||
local input = inv:get_stack("input", 1)
|
||||
if input:get_count() > 0 then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function update_formspec(m, progress)
|
||||
progress = progress or m:get_int "progress"
|
||||
local fluid = m:get_float "fluid"
|
||||
local capacity = m:get_int "fluid_capacity"
|
||||
local progressbar = progress == 0 and "rgt_progress_bg.png^[transformR270" or "rgt_progress_bg.png^[lowpart:"..progress..":rgt_progress_bg_active.png^[transformR270"
|
||||
local fluidcontainer = fluid == 0 and "rgt_fluid_container_bg.png" or "rgt_fluid_container_bg.png^[lowpart:"..(fluid /capacity *100)..":rgt_fluid_container_bg_filled.png"
|
||||
local fs = {"\
|
||||
formspec_version[10]\
|
||||
size[12,12]\
|
||||
", ui.list("context", "input", 2, 2, 1, 1), "\
|
||||
image[4,2;1,1;", progressbar, "]\
|
||||
image[7,1;1,3;", minetest.formspec_escape(fluidcontainer), "]\
|
||||
label[0.5,0.5;", fluid, " / ", capacity, "]\
|
||||
"}
|
||||
fs[#fs +1] = ui.list("current_player", "main", 1.125, 6.5, 8, 4)
|
||||
fs[#fs +1] = "\
|
||||
listring[]"
|
||||
|
||||
m:set_string("formspec", table.concat(fs))
|
||||
end
|
||||
|
||||
local function activate(pos, node, m)
|
||||
m:set_string("active", "true")
|
||||
node.name = "steam_generator_active"
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
local function deactivate(pos, node, m)
|
||||
m:set_string("active", "false")
|
||||
m:set_int("progress", 0)
|
||||
update_formspec(m)
|
||||
node.name = "steam_generator_idle"
|
||||
minetest.swap_node(pos, node)
|
||||
end
|
||||
|
||||
local function update(pos, elapsed)
|
||||
local node = minetest.get_node(pos)
|
||||
local m = minetest.get_meta(pos)
|
||||
local inv = m:get_inventory()
|
||||
|
||||
local active = m:get_string("active") == "true"
|
||||
|
||||
if can_work(node, m, inv) then
|
||||
if not active then
|
||||
active = true
|
||||
activate(pos, node, m)
|
||||
end
|
||||
|
||||
local progress = m:get_int("progress") +20
|
||||
|
||||
if progress >= 100 then
|
||||
local fluid = m:get_float "fluid"
|
||||
fluid = fluid +1
|
||||
m:set_float("fluid", fluid)
|
||||
|
||||
-- Consume an item.
|
||||
local s = inv:get_stack("input", 1)
|
||||
s:take_item()
|
||||
inv:set_stack("input", 1, s)
|
||||
|
||||
progress = 0
|
||||
end
|
||||
m:set_int("progress", progress)
|
||||
|
||||
update_formspec(m, progress)
|
||||
|
||||
elseif active then
|
||||
active = false
|
||||
deactivate(pos, node, m)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
rgt_machines.register_machine("steam_generator", {
|
||||
states = {
|
||||
idle = {
|
||||
tiles = {"rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_steam_generator_front.png"}
|
||||
},
|
||||
active = {
|
||||
tiles = {"rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_iron_block.png", "rgt_steam_generator_front_active.png"},
|
||||
drop = "steam_generator_idle",
|
||||
}
|
||||
},
|
||||
paramtype2 = "4dir",
|
||||
groups = {dig_immediate = 3},
|
||||
on_construct = function(pos)
|
||||
local m = minetest.get_meta(pos)
|
||||
local inv = m:get_inventory()
|
||||
inv:set_size("input", 1)
|
||||
|
||||
m:set_int("fluid_capacity", 10)
|
||||
m:set_string("active", "false")
|
||||
|
||||
update_formspec(m)
|
||||
|
||||
minetest.get_node_timer(pos):start(1)
|
||||
end,
|
||||
on_destruct = function(pos)
|
||||
local m = minetest.get_meta(pos)
|
||||
local inv = m:get_inventory()
|
||||
for i = 1, inv:get_size("input") do
|
||||
local item = minetest.add_item(pos, inv:get_stack("input", i))
|
||||
if item then
|
||||
item:set_velocity(vector.random_direction() *math.random(2, 3))
|
||||
end
|
||||
end
|
||||
end,
|
||||
allow_metadata_inventory_put = function(pos, list, idx, s, p)
|
||||
local inv = minetest.get_meta(pos):get_inventory()
|
||||
local meltable = minetest.registered_items[s:get_name()].groups.arc_furnace_meltable
|
||||
if meltable then
|
||||
if inv:room_for_item("input", s) then
|
||||
return s:get_count()
|
||||
elseif inv:room_for_item("input", s:take_item()) then
|
||||
return s:get_stack_max() -inv:get_stack("input", 1):get_count()
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end,
|
||||
on_timer = update
|
||||
})
|
||||
2
mods/rgt_machines/rgt_steam_generator/mod.conf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_steam_generator
|
||||
depends = rgt_machines
|
||||
|
After Width: | Height: | Size: 351 B |
|
After Width: | Height: | Size: 395 B |
|
|
@ -54,17 +54,20 @@ minetest.register_ore {
|
|||
|
||||
rgt.register_item("iron_ingot", {
|
||||
inventory_image = "rgt_iron_ingot.png",
|
||||
groups = {arc_furnace_meltable = 1}
|
||||
groups = {arc_furnace_meltable = 1},
|
||||
material = "iron",
|
||||
})
|
||||
|
||||
rgt.register_item("iron_lump", {
|
||||
inventory_image = "rgt_iron_lump.png",
|
||||
groups = {furnace_smeltable = 1}
|
||||
groups = {furnace_smeltable = 1},
|
||||
material = "iron",
|
||||
})
|
||||
|
||||
rgt.register_node("iron_block", {
|
||||
tiles = {"rgt_iron_block.png"},
|
||||
groups = {stone = 1}
|
||||
groups = {stone = 1},
|
||||
material = "iron",
|
||||
})
|
||||
|
||||
rgt.register_node("iron_ore", {
|
||||
|
|
@ -92,6 +95,72 @@ minetest.register_ore {
|
|||
},
|
||||
}
|
||||
|
||||
rgt.register_item("iron_plate", {
|
||||
inventory_image = "rgt_plate_iron.png",
|
||||
material = "iron",
|
||||
})
|
||||
|
||||
rgt.register_item("iron_rod", {
|
||||
inventory_image = "rgt_rod_iron.png",
|
||||
material = "iron",
|
||||
})
|
||||
|
||||
rgt.register_item("iron_gear", {
|
||||
inventory_image = "rgt_gear_iron.png",
|
||||
material = "iron",
|
||||
})
|
||||
|
||||
-- MARK: Copper
|
||||
|
||||
rgt.register_item("copper_ingot", {
|
||||
inventory_image = "rgt_copper_ingot.png",
|
||||
})
|
||||
|
||||
rgt.register_item("copper_lump", {
|
||||
inventory_image = "rgt_copper_lump.png",
|
||||
})
|
||||
|
||||
rgt.register_node("copper_block", {
|
||||
tiles = {"rgt_copper_block.png"},
|
||||
groups = {stone = 1}
|
||||
})
|
||||
|
||||
rgt.register_node("copper_ore", {
|
||||
tiles = {"rgt_stone.png^rgt_copper_ore.png"},
|
||||
drop = "copper_lump",
|
||||
groups = {stone = 1}
|
||||
})
|
||||
|
||||
minetest.register_ore {
|
||||
ore_type = "scatter",
|
||||
ore = "copper_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 = 9942,
|
||||
octaves = 3,
|
||||
persistence = 0.7
|
||||
},
|
||||
}
|
||||
|
||||
rgt.register_item("copper_plate", {
|
||||
inventory_image = "rgt_plate_copper.png"
|
||||
})
|
||||
|
||||
rgt.register_item("gold_rod", {
|
||||
inventory_image = "rgt_rod_copper.png"
|
||||
})
|
||||
|
||||
rgt.register_item("gold_gear", {
|
||||
inventory_image = "rgt_gear_copper.png"
|
||||
})
|
||||
|
||||
-- MARK: - Gold
|
||||
|
||||
|
|
@ -132,3 +201,15 @@ minetest.register_ore {
|
|||
persistence = 0.7
|
||||
},
|
||||
}
|
||||
|
||||
rgt.register_item("gold_plate", {
|
||||
inventory_image = "rgt_plate_gold.png"
|
||||
})
|
||||
|
||||
rgt.register_item("gold_rod", {
|
||||
inventory_image = "rgt_rod_gold.png"
|
||||
})
|
||||
|
||||
rgt.register_item("gold_gear", {
|
||||
inventory_image = "rgt_gear_gold.png"
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,2 +1,2 @@
|
|||
name = rgt_materials
|
||||
depends = rgt_world
|
||||
depends = rgt_world, rgt_casting_basin
|
||||
BIN
mods/rgt_materials/textures/rgt_copper_block.png
Normal file
|
After Width: | Height: | Size: 305 B |
BIN
mods/rgt_materials/textures/rgt_copper_ingot.png
Normal file
|
After Width: | Height: | Size: 291 B |
BIN
mods/rgt_materials/textures/rgt_copper_lump.png
Normal file
|
After Width: | Height: | Size: 373 B |
BIN
mods/rgt_materials/textures/rgt_copper_ore.png
Normal file
|
After Width: | Height: | Size: 686 B |
BIN
mods/rgt_materials/textures/rgt_gear_copper.png
Normal file
|
After Width: | Height: | Size: 355 B |
BIN
mods/rgt_materials/textures/rgt_gear_gold.png
Normal file
|
After Width: | Height: | Size: 364 B |
BIN
mods/rgt_materials/textures/rgt_gear_iron.png
Normal file
|
After Width: | Height: | Size: 325 B |
|
Before Width: | Height: | Size: 296 B After Width: | Height: | Size: 298 B |
BIN
mods/rgt_materials/textures/rgt_plate_copper.png
Normal file
|
After Width: | Height: | Size: 308 B |
BIN
mods/rgt_materials/textures/rgt_plate_gold.png
Normal file
|
After Width: | Height: | Size: 324 B |
BIN
mods/rgt_materials/textures/rgt_plate_iron.png
Normal file
|
After Width: | Height: | Size: 287 B |
BIN
mods/rgt_materials/textures/rgt_rod_copper.png
Normal file
|
After Width: | Height: | Size: 179 B |
BIN
mods/rgt_materials/textures/rgt_rod_gold.png
Normal file
|
After Width: | Height: | Size: 146 B |
BIN
mods/rgt_materials/textures/rgt_rod_iron.png
Normal file
|
After Width: | Height: | Size: 139 B |
2
mods/rgt_origins/mod.conf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_origins
|
||||
depends = rgt_player
|
||||
|
|
@ -170,8 +170,22 @@ local function generate_tree(min, max, base_x, base_y, base_z)
|
|||
end
|
||||
end
|
||||
|
||||
local function tree(min, max, x, y, z)
|
||||
|
||||
local function tree(vm, min, max, x, y, z)
|
||||
apple_tree={
|
||||
axiom="FFFFFAFFBF",
|
||||
rules_a="[&&&FFFFF&&FFFF][&&&++++FFFFF&&FFFF][&&&----FFFFF&&FFFF]",
|
||||
rules_b="[&&&++FFFFF&&FFFF][&&&--FFFFF&&FFFF][&&&------FFFFF&&FFFF]",
|
||||
trunk="oak_log",
|
||||
leaves="oak_leaves",
|
||||
angle=30,
|
||||
iterations=2,
|
||||
random_level=0,
|
||||
trunk_type="single",
|
||||
thin_branches=true,
|
||||
fruit_chance=10,
|
||||
fruit="stone"
|
||||
}
|
||||
minetest.spawn_tree_on_vmanip(vm, vector.new(x, y, z), apple_tree)
|
||||
end
|
||||
|
||||
|
||||
|
|
@ -228,9 +242,10 @@ minetest.register_on_generated(function(vm, min, max)
|
|||
end
|
||||
end
|
||||
|
||||
for _, x in pairs(trees) do
|
||||
tree(min, max, x.x, x.y, x.z)
|
||||
end
|
||||
|
||||
vm:set_data(vm_data)
|
||||
|
||||
for _, x in pairs(trees) do
|
||||
tree(vm, min, max, x.x, x.y, x.z)
|
||||
end
|
||||
vm:calc_lighting()
|
||||
end)
|
||||
|
|
@ -2,28 +2,29 @@ local ns = rgt
|
|||
ns.players = {}
|
||||
|
||||
Player = {
|
||||
listeners = {},
|
||||
new = function(p)
|
||||
local e = setmetatable({
|
||||
local m = setmetatable({
|
||||
name = p:get_player_name(),
|
||||
object = p
|
||||
}, {__index = Player})
|
||||
|
||||
local inv = p:get_inventory()
|
||||
inv:set_size("hand", 1)
|
||||
e:set_hotbar_size(8)
|
||||
m:set_hotbar_size(8)
|
||||
|
||||
e.textures = {_textures = {}}
|
||||
setmetatable(e.textures, {
|
||||
m.textures = {_textures = {}}
|
||||
setmetatable(m.textures, {
|
||||
__newindex = function(tbl, key, value)
|
||||
tbl._textures[idx] = value
|
||||
p:set_properties {
|
||||
textures = tbl._textures
|
||||
}
|
||||
end,
|
||||
__index = e.textures._textures
|
||||
__index = m.textures._textures
|
||||
})
|
||||
|
||||
e.hunger_bar = p:hud_add {
|
||||
m.hunger_bar = p:hud_add {
|
||||
type = "statbar",
|
||||
position = {x=0.5,y=1},
|
||||
offset = {x=10,y=-96},
|
||||
|
|
@ -36,29 +37,31 @@ Player = {
|
|||
text2 = "rgt_pumpkin_empty.png"
|
||||
}
|
||||
|
||||
e.props = p:get_properties()
|
||||
m.props = p:get_properties()
|
||||
|
||||
e.eye_height = 1.6
|
||||
m.eye_height = 1.6
|
||||
|
||||
e.hud = {}
|
||||
e.poi = {}
|
||||
m.hud = {}
|
||||
m.poi = {}
|
||||
|
||||
e.wearing = {}
|
||||
m.wearing = {}
|
||||
|
||||
e.logical_height_offset = 0
|
||||
e:update_hp(p:get_hp())
|
||||
m.logical_height_offset = 0
|
||||
m:update_hp(p:get_hp())
|
||||
|
||||
e.object:set_formspec_prepend [[
|
||||
m.object:set_formspec_prepend [[
|
||||
formspec_version[10]
|
||||
bgcolor[#000;true;#000c]
|
||||
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]
|
||||
style_type[button,image_button;border=false;bgimg=rgt_button_bg.png;bgimg_middle=8,8]
|
||||
listcolors[#fff0;#fff3;#0000;#444;#aaa]
|
||||
]]
|
||||
|
||||
e.inv = Inventory(p)
|
||||
m.inv = Inventory(p)
|
||||
|
||||
return e
|
||||
m:dispatch("init")
|
||||
|
||||
return m
|
||||
end,
|
||||
update_inv = function(m)
|
||||
local fs = "\
|
||||
|
|
@ -161,9 +164,11 @@ Player = {
|
|||
local pos = p:get_pos()
|
||||
pos.y = pos.y +m.eye_height
|
||||
|
||||
local ctl = p:get_player_control()
|
||||
|
||||
-- Animation
|
||||
if not m.in_third_person then
|
||||
local c = p:get_player_control()
|
||||
local c = ctl
|
||||
local moving = c.up or c.down or c.left or c.right
|
||||
|
||||
if moving then
|
||||
|
|
@ -206,7 +211,6 @@ Player = {
|
|||
else -- Third-person camera
|
||||
local c = m.camera.ref
|
||||
local me = m.focus and m.focus.ref or false
|
||||
local ctl = p:get_player_control()
|
||||
-- local lv = p:get_look_vertical()
|
||||
-- local lh = p:get_look_horizontal()
|
||||
-- local ldir = p:get_look_dir()
|
||||
|
|
@ -299,7 +303,7 @@ Player = {
|
|||
m.last_time = time
|
||||
end
|
||||
|
||||
-- Run on-hover callbacks
|
||||
-- MARK: Pointing callbacks
|
||||
m.pointed_node = nil
|
||||
|
||||
local pointed_found = false
|
||||
|
|
@ -312,6 +316,11 @@ Player = {
|
|||
if m.pointed_obj.on_unhover then
|
||||
m.pointed_obj:on_unhover(m)
|
||||
end
|
||||
if m.pointed_obj.on_interact and m.interaction_marker then
|
||||
m.object:hud_remove(m.interaction_marker)
|
||||
m.interaction_marker = nil
|
||||
m.interaction_start = nil
|
||||
end
|
||||
m.hover_trigger_range = nil
|
||||
end
|
||||
if (m.pointed_obj and not names_match and e.on_hover) or not m.pointed_obj then
|
||||
|
|
@ -325,6 +334,17 @@ Player = {
|
|||
pointed_found = true
|
||||
break
|
||||
end
|
||||
if e.on_interact and not e._no_interact and (not names_match or names_match and not m.interaction_marker) and (not e._can_interact or e:_can_interact(m)) then
|
||||
if m.interaction_marker then m.object:hud_remove(m.interaction_marker) end
|
||||
local dst = e.object:get_pos()
|
||||
if e._interact_marker_offset then dst = dst +e:_interact_marker_offset() end
|
||||
m.interaction_marker = m.object:hud_add {
|
||||
type = "image_waypoint",
|
||||
world_pos = dst,
|
||||
scale = {x=3, y=3},
|
||||
text = "rgt_rmb.png"
|
||||
}
|
||||
end
|
||||
end
|
||||
elseif pointed and pointed.type == "node" and not m.pointed_node then
|
||||
pointed.node_under = minetest.get_node(pointed.under)
|
||||
|
|
@ -335,49 +355,46 @@ Player = {
|
|||
if m.pointed_obj.on_unhover then
|
||||
m.pointed_obj:on_unhover(m)
|
||||
end
|
||||
if m.pointed_obj.on_interact and m.interaction_marker then
|
||||
m.object:hud_remove(m.interaction_marker)
|
||||
m.interaction_marker = nil
|
||||
m.interaction_start = nil
|
||||
end
|
||||
m.pointed_obj = nil
|
||||
m.hover_trigger_range = nil
|
||||
end
|
||||
|
||||
m.pos = pos
|
||||
-- MARK: Progressive interaction
|
||||
|
||||
-- Hold-to-interact handling
|
||||
if m.interacting_with and m.ctl.place then
|
||||
if ctl.place and m.ctl.place and m.pointed_obj and m.pointed_obj.on_interact and not m.pointed_obj._no_interact and (not m.pointed_obj._can_interact or m.pointed_obj:_can_interact(m)) 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
|
||||
local duration = (m.pointed_obj._interact_time or 1) *1000000
|
||||
local progress = (time -m.interaction_start) /duration
|
||||
if progress > 1.1 then
|
||||
m.pointed_obj:on_interact(m)
|
||||
m.interaction_start = nil
|
||||
m.interaction_marker:remove()
|
||||
m.object:hud_remove(m.interaction_marker)
|
||||
m.interaction_marker = nil
|
||||
elseif progress > 1 then
|
||||
m.object:hud_change(m.interaction_marker, "text", "rgt_rmb_100.png")
|
||||
elseif progress > 0.75 then
|
||||
m.object:hud_change(m.interaction_marker, "text", "rgt_rmb_75.png")
|
||||
elseif progress > 0.5 then
|
||||
m.object:hud_change(m.interaction_marker, "text", "rgt_rmb_50.png")
|
||||
elseif progress > 0.25 then
|
||||
m.object:hud_change(m.interaction_marker, "text", "rgt_rmb_25.png")
|
||||
end
|
||||
end
|
||||
elseif not ctl.place and m.interaction_start and (not m.pointed_obj or not m.pointed_obj._no_interact or m.pointed_obj._can_interact and m.pointed_obj:_can_interact(m)) then
|
||||
m.interaction_start = nil
|
||||
if m.interaction_marker then
|
||||
m.object:hud_change(m.interaction_marker, "text", "rgt_rmb.png")
|
||||
end
|
||||
end
|
||||
|
||||
m.pos = pos
|
||||
|
||||
-- Run on_wield callbacks
|
||||
local w = p:get_wielded_item()
|
||||
|
|
@ -397,6 +414,8 @@ Player = {
|
|||
|
||||
local while_wielded = def and def.while_wielded
|
||||
if while_wielded then while_wielded(m, w) end
|
||||
|
||||
m:dispatch("tick")
|
||||
end,
|
||||
set_hotbar_size = function(m, slots)
|
||||
local p = m.object
|
||||
|
|
@ -409,13 +428,15 @@ Player = {
|
|||
p:hud_set_hotbar_selected_image("rgt_hotbar_selected.png")
|
||||
end,
|
||||
deinit = function(m)
|
||||
m:dispatch("deinit")
|
||||
m.health_display:remove()
|
||||
m.wielditem_display:remove()
|
||||
rgt.players[m.name] = nil
|
||||
end
|
||||
}
|
||||
setmetatable(Player, {
|
||||
__call = function(_, ...) return Player.new(...) end
|
||||
__call = function(_, ...) return Player.new(...) end,
|
||||
__index = EventTarget
|
||||
})
|
||||
|
||||
|
||||
|
|
|
|||
BIN
mods/rgt_player/textures/rgt_rmb.png
Normal file
|
After Width: | Height: | Size: 143 B |
BIN
mods/rgt_player/textures/rgt_rmb_100.png
Normal file
|
After Width: | Height: | Size: 190 B |
BIN
mods/rgt_player/textures/rgt_rmb_25.png
Normal file
|
After Width: | Height: | Size: 175 B |
BIN
mods/rgt_player/textures/rgt_rmb_50.png
Normal file
|
After Width: | Height: | Size: 191 B |
BIN
mods/rgt_player/textures/rgt_rmb_75.png
Normal file
|
After Width: | Height: | Size: 191 B |
|
|
@ -18,6 +18,8 @@
|
|||
--]]
|
||||
|
||||
|
||||
-- MARK: Iron
|
||||
|
||||
rgt.register_tool("iron_sword", {
|
||||
inventory_image = "rgt_sword_iron.png",
|
||||
_wield_scale = 0.4,
|
||||
|
|
@ -58,7 +60,7 @@ minetest.register_chatcommand("iron", {
|
|||
end
|
||||
})
|
||||
|
||||
|
||||
-- MARK: Gold
|
||||
|
||||
rgt.register_tool("gold_sword", {
|
||||
inventory_image = "rgt_sword_gold.png",
|
||||
|
|
@ -100,3 +102,45 @@ minetest.register_chatcommand("gold", {
|
|||
end
|
||||
end
|
||||
})
|
||||
|
||||
-- MARK: Copper
|
||||
|
||||
rgt.register_tool("copper_sword", {
|
||||
inventory_image = "rgt_sword_copper.png",
|
||||
_wield_scale = 0.4,
|
||||
_wield_pos = vector.new(0, 0, 1)
|
||||
})
|
||||
|
||||
rgt.register_tool("copper_pick", {
|
||||
inventory_image = "rgt_pick_copper.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("copper_axe", {
|
||||
inventory_image = "rgt_axe_copper.png",
|
||||
_wield_scale = 0.4,
|
||||
_wield_pos = vector.new(0, 0, 1),
|
||||
})
|
||||
|
||||
rgt.register_tool("copper_shovel", {
|
||||
inventory_image = "rgt_shovel_copper.png",
|
||||
_wield_scale = 0.4,
|
||||
_wield_pos = vector.new(0, 0, 1)
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("copper", {
|
||||
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("copper_"..x))
|
||||
end
|
||||
end
|
||||
})
|
||||
|
|
|
|||
BIN
mods/rgt_tools/textures/rgt_axe_copper.png
Normal file
|
After Width: | Height: | Size: 264 B |
BIN
mods/rgt_tools/textures/rgt_pick_copper.png
Normal file
|
After Width: | Height: | Size: 305 B |
BIN
mods/rgt_tools/textures/rgt_shovel_copper.png
Normal file
|
After Width: | Height: | Size: 269 B |
BIN
mods/rgt_tools/textures/rgt_sword_copper.png
Normal file
|
After Width: | Height: | Size: 277 B |
0
mods/rgt_vehicles/modpack.conf
Normal file
|
|
@ -83,7 +83,8 @@ rgt.register_node("sand", {
|
|||
|
||||
rgt.register_node("oak_log", {
|
||||
tiles = {"rgt_oak_log_top.png", "rgt_oak_log_top.png", "rgt_oak_log_side.png"},
|
||||
groups = {dig_immediate = 3}
|
||||
groups = {dig_immediate = 3},
|
||||
paramtype2 = "facedir"
|
||||
})
|
||||
|
||||
rgt.register_node("oak_leaves", {
|
||||
|
|
@ -233,7 +234,8 @@ minetest.register_alias("mapgen_river_water_source", "red_glazed_terracotta:rive
|
|||
rgt.register_node("light", {
|
||||
tiles = {"[fill:1x1:0,0:#fed"},
|
||||
light_source = 14,
|
||||
paramtype = "light"
|
||||
paramtype = "light",
|
||||
description = "Test"
|
||||
})
|
||||
|
||||
minetest.register_ore {
|
||||
|
|
@ -246,7 +248,6 @@ minetest.register_ore {
|
|||
}
|
||||
|
||||
|
||||
|
||||
--minetest.register_decoration {
|
||||
-- deco_type = "schematic",
|
||||
-- place_on = "dirt_grass",
|
||||
|
|
@ -271,7 +272,7 @@ minetest.register_biome{
|
|||
depth_riverbed = 3,
|
||||
|
||||
node_dungeon = "cobble",
|
||||
node_dungeon_alt = "stone",
|
||||
node_dungeon_alt = "stone_brick_large",
|
||||
|
||||
|
||||
y_max = 3000,
|
||||
|
|
@ -295,7 +296,7 @@ minetest.register_biome{
|
|||
depth_riverbed = 3,
|
||||
|
||||
node_dungeon = "cobble",
|
||||
node_dungeon_alt = "stone",
|
||||
node_dungeon_alt = "stone_brick_large",
|
||||
|
||||
|
||||
y_max = 1,
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ function ns.update_stair(pos, basename, leaf)
|
|||
node.param2 = minetest.dir_to_facedir(-neighbors[1]:rotate(vector.new(0, math.pi /2, 0)))
|
||||
minetest.swap_node(pos, node)
|
||||
elseif #neighbors > 1 then
|
||||
-- Just ue the first two neighbors.
|
||||
-- Just use the first two neighbors.
|
||||
if neighbors[1].x ~= 0 and neighbors[2].x ~= 0 or neighbors[1].z ~= 0 and neighbors[2].z ~= 0 then
|
||||
node.name = basename.."_stair"
|
||||
node.param2 = minetest.dir_to_facedir(neighbors[1])
|
||||
|
|
|
|||