Improve mapgen, add grass, and include the fill tool.
|
|
@ -1,3 +1,4 @@
|
|||
title = Red Glazed Terracotta
|
||||
description = Segmentation fault (core dumped).
|
||||
disabled_settings = !enable_damage
|
||||
default_mapgen = valleys
|
||||
|
|
@ -67,6 +67,39 @@ setmetatable(EventTarget, {
|
|||
__call = function(_, ...) return EventTarget.init(...) end
|
||||
})
|
||||
|
||||
StateMachine = {
|
||||
init = function(obj, states)
|
||||
local super = EventTarget()
|
||||
local e = {
|
||||
states = states,
|
||||
active_states = {},
|
||||
obj = obj
|
||||
}
|
||||
return setmetatable(e, {__index = super})
|
||||
end,
|
||||
add_state = function(e, state)
|
||||
if e.active_states[state] then return false end
|
||||
e.states[state]:add(e.obj)
|
||||
e.active_states[state] = true
|
||||
return true
|
||||
end,
|
||||
tick = function(e)
|
||||
for k in pairs(e.active_states) do
|
||||
e.states[k]:tick(e.obj)
|
||||
end
|
||||
end,
|
||||
remove_state = function(e, state)
|
||||
if not e.active_states[state] then return false end
|
||||
e.states[state]:remove(e.obj)
|
||||
e.active_states[state] = nil
|
||||
return true
|
||||
end,
|
||||
}
|
||||
setmetatable(StateMachine, {
|
||||
__call = function(_, ...) return StateMachine.init(...) end,
|
||||
__index = EventTarget()
|
||||
})
|
||||
|
||||
rgt = {
|
||||
adjacent_neighbor_offests = {
|
||||
vector.new(0,0,1),
|
||||
|
|
@ -85,7 +118,8 @@ rgt = {
|
|||
vector.new(-1,0,0),
|
||||
},
|
||||
nodes_to_content_ids = {},
|
||||
content_ids_to_nodes = {}
|
||||
content_ids_to_nodes = {},
|
||||
vm_data = {},
|
||||
}
|
||||
local ns = rgt
|
||||
|
||||
|
|
@ -151,6 +185,60 @@ function ns.register_entity(name, def)
|
|||
minetest.register_entity(name, def)
|
||||
end
|
||||
|
||||
-- Make node dig particles denser.
|
||||
minetest.register_on_dignode(function(pos, node, digger)
|
||||
local gravity = tonumber(core.settings:get("movement_gravity")) or 9.81
|
||||
local def = minetest.registered_nodes[node.name]
|
||||
minetest.add_particlespawner({
|
||||
amount = 128,
|
||||
time = 0.001,
|
||||
minpos = vector.offset(pos, -0.35, -0.35, -0.35),
|
||||
maxpos = vector.offset(pos, 0.35, 0.35, 0.35),
|
||||
minvel = vector.new(-1.7, 0, -1.7),
|
||||
maxvel = vector.new(1.7, 3.5, 1.7),
|
||||
minacc = vector.new(0, -gravity *2, 0),
|
||||
maxacc = vector.new(0, -gravity *2, 0),
|
||||
minexptime = 0, maxexptime = 1,
|
||||
minsize = 0, maxsize = 0, -- random
|
||||
node = node,
|
||||
minsize = 0.5,
|
||||
maxsize = 1.4,
|
||||
blend = (def and def.use_texture_alpha == "blend") and "blend" or "clip",
|
||||
})
|
||||
end)
|
||||
|
||||
-- Fills the area from pos1 to pos2 with the node named `node`.
|
||||
function ns.fill_area(pos1, pos2, node)
|
||||
local minp = vector.new(math.min(pos1.x, pos2.x), math.min(pos1.y, pos2.y), math.min(pos1.z, pos2.z))
|
||||
local maxp = vector.new(math.max(pos1.x, pos2.x), math.max(pos1.y, pos2.y), math.max(pos1.z, pos2.z))
|
||||
local vm = minetest.get_voxel_manip(pos1, pos2)
|
||||
local min, max = vm:get_emerged_area()
|
||||
local va = VoxelArea(min, max)
|
||||
local data = ns.vm_data
|
||||
|
||||
vm:get_data(data)
|
||||
|
||||
local c_node = minetest.get_content_id(node)
|
||||
for i in va:iterp(minp, maxp) do
|
||||
data[i] = c_node
|
||||
end
|
||||
|
||||
vm:set_data(data)
|
||||
vm:write_to_map()
|
||||
if vm.close then vm:close() end
|
||||
end
|
||||
|
||||
-- Get a flat texture that may represent the given node (using the first tile).
|
||||
function ns.get_node_texture(node)
|
||||
local def = minetest.registered_nodes[node]
|
||||
if not def or not def.tiles then return "blank.png" end
|
||||
local tx = def.tiles[1]
|
||||
if type(tx) == "string" then
|
||||
return tx
|
||||
end
|
||||
return tx.name or "blank.png"
|
||||
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 = {
|
||||
|
|
|
|||
158
mods/rgt_gadgets/rgt_fill_tool/init.lua
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
|
||||
minetest.register_entity(":red_glazed_terracotta:fill_tool_display", {
|
||||
initial_properties = {
|
||||
static_save = false,
|
||||
visual = "cube",
|
||||
textures = {"rgt_fill_tool_display_start.png", "rgt_fill_tool_display_start.png", "rgt_fill_tool_display_start.png", "rgt_fill_tool_display_start.png", "rgt_fill_tool_display_start.png", "rgt_fill_tool_display_start.png"},
|
||||
glow = 15,
|
||||
visual_size = vector.new(1, 1, 1) *1.1,
|
||||
pointable = false
|
||||
}
|
||||
})
|
||||
|
||||
--minetest.register_entity(":travelers_notebook:fill_tool_range_display", {
|
||||
-- initial_properties = {
|
||||
-- static_save = false,
|
||||
-- textures = {"blank.png"},
|
||||
-- glow = 15,
|
||||
-- visual_size = vector.new(1, 1, 1) *0.6,
|
||||
-- pointable = false
|
||||
-- }
|
||||
--})
|
||||
|
||||
local function get_shape_fill_display_pos(m)
|
||||
local pos = m.pos
|
||||
local dir = m.object:get_look_dir()
|
||||
local node = minetest.raycast(pos, pos +(dir *(m.shape_fill_range or 5)), false):next()
|
||||
if node and node.under then
|
||||
pos = node.under
|
||||
else
|
||||
pos = (pos +(dir *(m.shape_fill_range or 5))):round()
|
||||
end
|
||||
return pos
|
||||
end
|
||||
rgt.register_item("fill_tool", {
|
||||
stack_max = 1,
|
||||
inventory_image = "rgt_shape_fill_tool.png",
|
||||
range = 0,
|
||||
touch_interaction = "short_dig_long_place",
|
||||
on_use = function(s, p)
|
||||
local m = rgt.players[p:get_player_name()]
|
||||
if m.node_picker then
|
||||
local pos = m.pos
|
||||
local dir = m.object:get_look_dir()
|
||||
-- local obj = minetest.raycast(pos +dir, pos +(dir *15), true, false, {nodes = {}}):next()
|
||||
if m.pointed_obj or obj and obj.type == "object" then
|
||||
local e = m.pointed_obj
|
||||
if e.node then
|
||||
local sm = s:get_meta()
|
||||
if e.node == "air" then
|
||||
sm:set_string("inventory_image", "")
|
||||
else
|
||||
local def = minetest.registered_nodes[e.node]
|
||||
if def._rgt_tileset_master then e.node = def._rgt_tileset_master end
|
||||
local tx = rgt.get_node_texture(e.node)
|
||||
sm:set_string("inventory_image", "[combine:16x16:3,3="..tx.."\\^[resize\\:10x10:0,0=rgt_shape_fill_tool.png")
|
||||
end
|
||||
sm:set_string("node", e.node)
|
||||
rgt.close_node_picker(m)
|
||||
end
|
||||
end
|
||||
else
|
||||
local pos = get_shape_fill_display_pos(rgt.players[p:get_player_name()])
|
||||
if not pos then return end
|
||||
local m = s:get_meta()
|
||||
local node = minetest.get_node(pos).name
|
||||
if node == "air" then
|
||||
m:set_string("inventory_image", "")
|
||||
else
|
||||
local def = minetest.registered_nodes[node]
|
||||
if def._rgt_tileset_master then node = def._rgt_tileset_master end
|
||||
local tx = rgt.get_node_texture(node)
|
||||
m:set_string("inventory_image", "[combine:16x16:3,3="..tx.."\\^[resize\\:10x10:0,0=rgt_shape_fill_tool.png")
|
||||
end
|
||||
m:set_string("node", node)
|
||||
end
|
||||
return s
|
||||
end,
|
||||
on_wield = function(m)
|
||||
local pos = get_shape_fill_display_pos(m)
|
||||
m.shape_fill_display_start = minetest.add_entity(pos, "red_glazed_terracotta:fill_tool_display")
|
||||
m.shape_fill_display_start:set_observers{[m.name] = true}
|
||||
m.shape_fill_range = m.shape_fill_range or 5
|
||||
m.shape_fill_last_range = m.shape_fill_range
|
||||
end,
|
||||
while_wielded = function(m, s)
|
||||
local pos = get_shape_fill_display_pos(m)
|
||||
if not m.shape_fill_display_start and not m.node_picker then
|
||||
m.shape_fill_display_start = minetest.add_entity(pos, "red_glazed_terracotta:fill_tool_display")
|
||||
m.shape_fill_display_start:set_observers{[m.name] = true}
|
||||
end
|
||||
|
||||
if m.shape_fill_display_start and m.node_picker then
|
||||
m.shape_fill_display_start:remove()
|
||||
m.shape_fill_display_start = nil
|
||||
end
|
||||
|
||||
if m.shape_fill_display_end then
|
||||
m.shape_fill_display_end:set_pos(pos)
|
||||
elseif m.shape_fill_display_start then
|
||||
m.shape_fill_display_start:set_pos(pos)
|
||||
end
|
||||
|
||||
-- if m.shape_fill_zoom_view then
|
||||
-- local pitch = m.object:get_look_vertical()
|
||||
-- if math.abs(pitch) > math.rad(15) then
|
||||
-- m.shape_fill_range = math.max(5, m.shape_fill_range -(0.2 *pitch))
|
||||
-- if math.abs(m.shape_fill_range -(m.shape_fill_last_range or 5)) > 1 then
|
||||
-- m.shape_fill_zoom_view:set_properties{
|
||||
-- textures = {libarchive.rasterize(tostring(math.round(m.shape_fill_range or 5)), 40, 40, 0, 0)}
|
||||
-- }
|
||||
-- m.shape_fill_last_range = range
|
||||
-- end
|
||||
-- end
|
||||
-- end
|
||||
--
|
||||
-- if m.ctl.zoom and not m.shape_fill_zoom_view then
|
||||
-- m.shape_fill_zoom_view = minetest.add_entity(pos, "red_glazed_terracotta:fill_tool_range_display")
|
||||
-- m.shape_fill_zoom_view:set_properties{
|
||||
-- textures = {libarchive.rasterize(tostring(math.round(m.shape_fill_range) or 5), 40, 40, 0, 0)}
|
||||
-- }
|
||||
-- m.shape_fill_zoom_view:set_attach(m.object, "", vector.new(0, 20, 20), nil, true)
|
||||
-- elseif not m.ctl.zoom and m.shape_fill_zoom_view then
|
||||
-- m.shape_fill_zoom_view:remove()
|
||||
-- m.shape_fill_zoom_view = nil
|
||||
-- end
|
||||
|
||||
if m.shape_fill_display_end and not m.ctl.place then
|
||||
local node = s:get_meta():get("node") or "air"
|
||||
rgt.fill_area(m.shape_fill_start, m.shape_fill_display_end:get_pos():round(), node)
|
||||
|
||||
m.shape_fill_display_end:remove()
|
||||
m.shape_fill_display_end = nil
|
||||
elseif m.shape_fill_display_start and not m.shape_fill_display_end and m.ctl.place then
|
||||
m.shape_fill_start = m.shape_fill_display_start:get_pos():round()
|
||||
|
||||
m.shape_fill_display_end = minetest.add_entity(get_shape_fill_display_pos(m), "red_glazed_terracotta:fill_tool_display")
|
||||
m.shape_fill_display_end:set_properties{
|
||||
textures = {"rgt_fill_tool_display_end.png", "rgt_fill_tool_display_end.png", "rgt_fill_tool_display_end.png", "rgt_fill_tool_display_end.png", "rgt_fill_tool_display_end.png", "rgt_fill_tool_display_end.png"},
|
||||
}
|
||||
m.shape_fill_display_end:set_observers{[m.name] = true}
|
||||
end
|
||||
end,
|
||||
on_unwield = function(m)
|
||||
if m.shape_fill_display_start then
|
||||
m.shape_fill_display_start:remove()
|
||||
m.shape_fill_display_start = nil
|
||||
end
|
||||
if m.shape_fill_display_end then
|
||||
m.shape_fill_display_end:remove()
|
||||
m.shape_fill_display_end = nil
|
||||
end
|
||||
if m.shape_fill_zoom_view then
|
||||
m.shape_fill_zoom_view:remove()
|
||||
m.shape_fill_zoom_view = nil
|
||||
end
|
||||
m.shape_fill_start = nil
|
||||
end
|
||||
})
|
||||
2
mods/rgt_gadgets/rgt_fill_tool/mod.conf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_fill_tool
|
||||
depends = rgt_player
|
||||
|
After Width: | Height: | Size: 154 B |
|
After Width: | Height: | Size: 154 B |
BIN
mods/rgt_gadgets/rgt_fill_tool/textures/rgt_shape_fill_tool.png
Normal file
|
After Width: | Height: | Size: 254 B |
|
|
@ -1,10 +1,28 @@
|
|||
rgt_inv = {}
|
||||
local ns = rgt_inv
|
||||
|
||||
local creative_inv = minetest.create_detached_inventory("rgt_creative_inv", {
|
||||
allow_take = function()
|
||||
return -1
|
||||
end
|
||||
})
|
||||
local num_items = 0
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
for name, def in pairs(minetest.registered_items) do
|
||||
if not def._variant then
|
||||
creative_inv:set_size("main", num_items +1)
|
||||
creative_inv:set_stack("main", num_items, ItemStack(name.." "..def.stack_max))
|
||||
num_items = num_items +1
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Inventory = setmetatable({
|
||||
new = function(p)
|
||||
local e = setmetatable({
|
||||
player = p,
|
||||
inv = p:get_inventory(),
|
||||
state = {
|
||||
proximate_machines = {}
|
||||
}
|
||||
|
|
@ -18,6 +36,12 @@ Inventory = setmetatable({
|
|||
e:rebuild()
|
||||
end
|
||||
})
|
||||
|
||||
e.inv:set_size("hand", 1)
|
||||
e.inv:set_size("craft", 4)
|
||||
-- This is important for shaped crafting to work properly.
|
||||
e.inv:set_width("craft", 2)
|
||||
|
||||
e:rebuild()
|
||||
return e
|
||||
end,
|
||||
|
|
@ -26,33 +50,29 @@ Inventory = setmetatable({
|
|||
formspec_version[10]\
|
||||
size[12,10]\
|
||||
style_type[button,image_button;border=false]\
|
||||
"}
|
||||
for x = 0, 7 do
|
||||
for y = 0, 3 do
|
||||
",
|
||||
ui.list("current_player", "main", 1.125, 4.5, 8, 4),
|
||||
}
|
||||
|
||||
if true or e.player._creative then
|
||||
fs[#fs +1] = "scroll_container[1,1;10,3;creativescroll;vertical;;0]"
|
||||
fs[#fs +1] = ui.list("detached:rgt_creative_inv", "main", 0.05, 0.05, 8, math.ceil(num_items /8))
|
||||
fs[#fs +1] = "scroll_container_end[]\
|
||||
scrollbar[11,1;0.2,3;vertical;creativescroll;]"
|
||||
else
|
||||
fs[#fs +1] = ui.list("current_player", "craft", 2, 1, 2, 2)
|
||||
fs[#fs +1] = "\
|
||||
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 +1] = "\
|
||||
style_type[image_button;noclip=true;bgimg=rgt_button_bg.png;bgimg_middle=8,8]\
|
||||
"
|
||||
local i = 0
|
||||
for _, x in ipairs(e.state.proximate_machines) do
|
||||
local y = i > 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;]\
|
||||
image[4.7,1.5;1,1;rgt_progress_bg.png^\\[transformR270]\
|
||||
"
|
||||
fs[#fs +1] = ui.list("current_player", "craftpreview", 6, 1.5, 1, 1)
|
||||
end
|
||||
|
||||
e.player:set_inventory_formspec(table.concat(fs))
|
||||
end,
|
||||
on_action = function(e, data)
|
||||
|
||||
set_craft_grid_size = function(e, size)
|
||||
e.inv:set_size("craft", size *size)
|
||||
e.inv:set_width("craft", size)
|
||||
end
|
||||
}, {
|
||||
__call = function(_, ...)
|
||||
|
|
@ -60,31 +80,6 @@ Inventory = setmetatable({
|
|||
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)
|
||||
|
|
|
|||
|
|
@ -1,2 +0,0 @@
|
|||
name = rgt_alloy_furnace
|
||||
depends = rgt_machines
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
name = rgt_arc_furnace
|
||||
depends = rgt_machines
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
name = rgt_casting_basin
|
||||
depends = rgt_machines
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
name = rgt_furnace
|
||||
depends = rgt_machines
|
||||
|
|
@ -1,171 +1,7 @@
|
|||
--[[
|
||||
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"
|
||||
|
||||
|
|
|
|||
0
mods/rgt_machines/rgt_machines_electric/modpack.conf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_alloy_furnace
|
||||
depends = rgt_machines_electric
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_arc_furnace
|
||||
depends = rgt_machines_electric
|
||||
|
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 357 B |
|
Before Width: | Height: | Size: 393 B After Width: | Height: | Size: 393 B |
|
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B |
|
Before Width: | Height: | Size: 116 B After Width: | Height: | Size: 116 B |
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_casting_basin
|
||||
depends = rgt_machines_electric
|
||||
|
Before Width: | Height: | Size: 167 B After Width: | Height: | Size: 167 B |
|
Before Width: | Height: | Size: 173 B After Width: | Height: | Size: 173 B |
|
Before Width: | Height: | Size: 107 B After Width: | Height: | Size: 107 B |
|
Before Width: | Height: | Size: 262 B After Width: | Height: | Size: 262 B |
|
Before Width: | Height: | Size: 303 B After Width: | Height: | Size: 303 B |
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_furnace
|
||||
depends = rgt_machines_electric
|
||||
|
|
@ -0,0 +1,170 @@
|
|||
--[[
|
||||
List of machines:
|
||||
- Arc furnace: Melts materials into their liquid form
|
||||
--]]
|
||||
|
||||
local ns = rgt_machines
|
||||
extend(ns, {
|
||||
registered_machines = {},
|
||||
networks = {}
|
||||
})
|
||||
|
||||
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"
|
||||
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_machines_electric
|
||||
depends = rgt_machines
|
||||
|
Before Width: | Height: | Size: 231 B 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 |
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_steam_generator
|
||||
depends = rgt_machines_electric
|
||||
|
Before Width: | Height: | Size: 351 B After Width: | Height: | Size: 351 B |
|
Before Width: | Height: | Size: 395 B After Width: | Height: | Size: 395 B |
0
mods/rgt_machines/rgt_machines_mechanical/modpack.conf
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
local ns = rgt_machines
|
||||
|
||||
ns.components = {}
|
||||
|
||||
--[[
|
||||
{
|
||||
name = "...", -- The component's name.
|
||||
attach_points
|
||||
}
|
||||
--]]
|
||||
function ns.register_component(def)
|
||||
ns.components[def.name] = def
|
||||
end
|
||||
|
||||
function ns.register_plate(name, def)
|
||||
rgt.register_item(name, def)
|
||||
end
|
||||
|
||||
|
||||
rgt.register_node("hand_crank", {
|
||||
mesh = "rgt_hand_crank.gltf"
|
||||
})
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_machines_mechanical
|
||||
depends = rgt_machines
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
name = rgt_steam_generator
|
||||
depends = rgt_machines
|
||||
|
|
@ -16,6 +16,20 @@
|
|||
- Gravel
|
||||
--]]
|
||||
|
||||
-- MARK: - Wood
|
||||
|
||||
rgt.register_item("stick", {
|
||||
inventory_image = "rgt_stick.png"
|
||||
})
|
||||
|
||||
minetest.register_craft {
|
||||
recipe = {
|
||||
{"group:planks", "group:planks"},
|
||||
{"group:planks", "group:planks"},
|
||||
},
|
||||
output = "workbench"
|
||||
}
|
||||
|
||||
-- MARK: - Coal
|
||||
|
||||
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 305 B After Width: | Height: | Size: 308 B |
|
Before Width: | Height: | Size: 291 B After Width: | Height: | Size: 298 B |
|
Before Width: | Height: | Size: 355 B After Width: | Height: | Size: 361 B |
|
Before Width: | Height: | Size: 308 B After Width: | Height: | Size: 316 B |
|
Before Width: | Height: | Size: 179 B After Width: | Height: | Size: 145 B |
57
mods/rgt_origins/init.lua
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
local ns = rgt
|
||||
|
||||
ns.origins = {}
|
||||
|
||||
local db = minetest.get_mod_storage()
|
||||
|
||||
--[[
|
||||
{
|
||||
name = "human", -- The name of this origin.
|
||||
label = "Human", -- The user-facing name.
|
||||
base_hp = 20, -- The base HP of this origin.
|
||||
properties = {...}, -- Object properties overridden by this origin.
|
||||
abilities = {
|
||||
|
||||
},
|
||||
on_apply = function(m) end, -- Called when this origin is first applied to a player.
|
||||
on_join = function(m) end, -- Called when a player with this origin joins.
|
||||
on_leave = function(m) end, -- Called when a player with this origin leaves.
|
||||
tick = function(m) end, -- Called every globalstep for each player that has this origin.
|
||||
}
|
||||
--]]
|
||||
function ns.register_origin(def)
|
||||
ns.origins[def.name] = def
|
||||
end
|
||||
|
||||
include_all "origins"
|
||||
|
||||
|
||||
local REALM_START = 30500
|
||||
local REALM_END = 31000
|
||||
|
||||
rgt_realms.register_realm {
|
||||
name = "startroom",
|
||||
label = "Start Room",
|
||||
min = vector.new(-100, REALM_START, -100),
|
||||
max = vector.new(100, REALM_END, 100),
|
||||
sky = {
|
||||
type = "plain",
|
||||
base_color = "#000",
|
||||
-- fog = {
|
||||
-- fog_distance = 20,
|
||||
-- fog_start = 0.3,
|
||||
-- fog_color = "#aab"
|
||||
-- }
|
||||
}
|
||||
}
|
||||
|
||||
if not db:contains "initialized" then
|
||||
minetest.after(0, function()
|
||||
local pos = vector.new(0, REALM_START +100, 0)
|
||||
minetest.emerge_area(pos, pos, function()
|
||||
say(pos:to_string())
|
||||
minetest.set_node(pos, {name = "stone"})
|
||||
end)
|
||||
db:set_string("initialized", "true")
|
||||
end)
|
||||
end
|
||||
0
mods/rgt_origins/origins/human.lua
Normal file
|
|
@ -9,8 +9,6 @@ Player = {
|
|||
object = p
|
||||
}, {__index = Player})
|
||||
|
||||
local inv = p:get_inventory()
|
||||
inv:set_size("hand", 1)
|
||||
m:set_hotbar_size(8)
|
||||
|
||||
m.textures = {_textures = {}}
|
||||
|
|
@ -431,6 +429,16 @@ Player = {
|
|||
m:dispatch("deinit")
|
||||
m.health_display:remove()
|
||||
m.wielditem_display:remove()
|
||||
|
||||
-- Unwield the wielded item. This ensures that if wielding an item creates side effects
|
||||
-- (e.g. temporary entities while wielded), those side effects will not remain in effect
|
||||
-- when the player leaves the game.
|
||||
local w = m.object:get_wielded_item()
|
||||
local wname = w:get_name()
|
||||
local def = minetest.registered_items[wname]
|
||||
local onunselect = def and def.on_unwield
|
||||
if onunselect then onunselect(m) end
|
||||
|
||||
rgt.players[m.name] = nil
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 264 B After Width: | Height: | Size: 259 B |
|
Before Width: | Height: | Size: 305 B After Width: | Height: | Size: 308 B |
|
Before Width: | Height: | Size: 269 B After Width: | Height: | Size: 275 B |
|
Before Width: | Height: | Size: 277 B After Width: | Height: | Size: 275 B |
30
mods/rgt_workbench/init.lua
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
local ns = rgt
|
||||
|
||||
|
||||
rgt.register_node("workbench", {
|
||||
on_construct = function()
|
||||
|
||||
end,
|
||||
on_rightclick = function(pos, node, p)
|
||||
local name = p:get_player_name()
|
||||
local fs = {
|
||||
"formspec_version[10]\
|
||||
size[12,11]\
|
||||
",
|
||||
ui.list("current_player", "main", 1.125, 5.5, 8, 4),
|
||||
ui.list("current_player", "craft", 2, 1, 3, 3),
|
||||
"listring[]\n",
|
||||
ui.list("current_player", "craftpreview", 6, 2.1, 1, 1)
|
||||
}
|
||||
rgt.players[name].inv:set_craft_grid_size(3)
|
||||
minetest.show_formspec(name, "workbench", table.concat(fs))
|
||||
end
|
||||
})
|
||||
|
||||
|
||||
minetest.register_on_player_receive_fields(function(p, form, data)
|
||||
if form == "workbench" and data.quit then
|
||||
local name = p:get_player_name()
|
||||
rgt.players[name].inv:set_craft_grid_size(2)
|
||||
end
|
||||
end)
|
||||
2
mods/rgt_workbench/mod.conf
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
name = rgt_workbench
|
||||
depends = rgt_base
|
||||
71
mods/rgt_world/biomes.lua
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
minetest.register_biome {
|
||||
name = "forest",
|
||||
|
||||
node_top = "dirt_grass",
|
||||
depth_top = 1,
|
||||
|
||||
node_filler = "dirt",
|
||||
depth_filler = 5,
|
||||
|
||||
node_riverbed = "dirt",
|
||||
depth_riverbed = 3,
|
||||
|
||||
node_dungeon = "cobble",
|
||||
node_dungeon_alt = "stone_brick_large",
|
||||
|
||||
|
||||
y_max = 3000,
|
||||
y_min = 2,
|
||||
vertical_blend = 2,
|
||||
|
||||
heat_point = 50,
|
||||
humidity_point = 50,
|
||||
}
|
||||
|
||||
minetest.register_biome {
|
||||
name = "plains",
|
||||
|
||||
node_top = "dirt_grass",
|
||||
depth_top = 1,
|
||||
|
||||
node_filler = "dirt",
|
||||
depth_filler = 5,
|
||||
|
||||
node_riverbed = "dirt",
|
||||
depth_riverbed = 3,
|
||||
|
||||
node_dungeon = "cobble",
|
||||
node_dungeon_alt = "stone_brick_large",
|
||||
|
||||
|
||||
y_max = 3000,
|
||||
y_min = 2,
|
||||
vertical_blend = 2,
|
||||
|
||||
heat_point = 50,
|
||||
humidity_point = 30,
|
||||
}
|
||||
|
||||
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_brick_large",
|
||||
|
||||
|
||||
y_max = 1,
|
||||
y_min = -3,
|
||||
vertical_blend = 1,
|
||||
|
||||
heat_point = 50,
|
||||
humidity_point = 50,
|
||||
}
|
||||
162
mods/rgt_world/config.lua
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
-- This file configures the Valleys mapgen settings to produce much larger-scale, more explorable terrain.
|
||||
-- These settings were originally posted by voxelproof on the Minetest forum: https://forum.luanti.org/viewtopic.php?p=336441#p336441
|
||||
|
||||
minetest.set_mapgen_setting_noiseparams("mgvalleys_np_terrain_height", {
|
||||
flags = "defaults",
|
||||
lacunarity = 1,
|
||||
offset = -10,
|
||||
scale = 1000,
|
||||
spread = vector.new(2048,2048,4096),
|
||||
seed = 4541,
|
||||
octaves = 6,
|
||||
persistence = 0.45,
|
||||
}, true)
|
||||
minetest.set_mapgen_setting_noiseparams("mgvalleys_np_inter_valley_slope", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 0.5,
|
||||
scale = 0.5,
|
||||
spread = vector.new(128,128,1024),
|
||||
seed = 746,
|
||||
octaves = 1,
|
||||
persistence = 1,
|
||||
}, true)
|
||||
minetest.set_mapgen_setting_noiseparams("mgvalleys_np_inter_valley_fill", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = vector.new(256,512,256),
|
||||
seed = 1993,
|
||||
octaves = 6,
|
||||
persistence = 0.8,
|
||||
}, true)
|
||||
minetest.set_mapgen_setting_noiseparams("mgvalleys_np_filler_depth", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 0,
|
||||
scale = 1.2,
|
||||
spread = vector.new(256,256,256),
|
||||
seed = 1605,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
}, true)
|
||||
minetest.set_mapgen_setting_noiseparams("mgvalleys_np_massive_caves", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = vector.new(512,256,256),
|
||||
seed = 59033,
|
||||
octaves = 6,
|
||||
persistence = 0.63,
|
||||
}, true)
|
||||
minetest.set_mapgen_setting_noiseparams("mgvalleys_np_cave2", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 0,
|
||||
scale = 23, -- 13
|
||||
spread = vector.new(67,67,67),
|
||||
seed = 10325,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
}, true)
|
||||
minetest.set_mapgen_setting_noiseparams("mgvalleys_np_cave1", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 0,
|
||||
scale = 23, -- 13
|
||||
spread = vector.new(61,61,61),
|
||||
seed = 52534,
|
||||
octaves = 3,
|
||||
persistence = 0.3,
|
||||
}, true)
|
||||
--mgvalleys_cave_width = 0.01
|
||||
--mgvalleys_river_size = 2
|
||||
--mg_flags = caves, dungeons, light, decorations
|
||||
--chunksize = 5
|
||||
--mgvalleys_lava_features = 0
|
||||
--mg_name = valleys
|
||||
--mapgen_limit = 31000
|
||||
--water_level = 1
|
||||
--seed = 18446744073709545565
|
||||
minetest.set_mapgen_setting_noiseparams("mgvalleys_np_rivers", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 0,
|
||||
scale = 2,
|
||||
spread = vector.new(512,512,128),
|
||||
seed = -6050,
|
||||
octaves = 5,
|
||||
persistence = 0.6,
|
||||
}, true)
|
||||
minetest.set_mapgen_setting_noiseparams("mg_biome_np_heat", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = vector.new(1000,1000,1000),
|
||||
seed = 5349,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
}, true)
|
||||
--mgvalleys_water_features = 0
|
||||
minetest.set_mapgen_setting_noiseparams("mg_biome_np_heat_blend", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 0,
|
||||
scale = 1.5,
|
||||
spread = vector.new(8,8,8),
|
||||
seed = 13,
|
||||
octaves = 2,
|
||||
persistence = 1,
|
||||
}, true)
|
||||
minetest.set_mapgen_setting_noiseparams("mg_biome_np_humidity", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 50,
|
||||
scale = 50,
|
||||
spread = vector.new(1000,1000,1000),
|
||||
seed = 842,
|
||||
octaves = 3,
|
||||
persistence = 0.5,
|
||||
}, true)
|
||||
minetest.set_mapgen_setting_noiseparams("mg_biome_np_humidity_blend", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 0,
|
||||
scale = 1.5,
|
||||
spread = vector.new(8,8,8),
|
||||
seed = 90003,
|
||||
octaves = 2,
|
||||
persistence = 1,
|
||||
}, true)
|
||||
minetest.set_mapgen_setting("mgvalleys_spflags", "altitude_chill, humid_rivers")
|
||||
minetest.set_mapgen_setting_noiseparams("mgvalleys_np_valley_depth", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 5,
|
||||
scale = 4,
|
||||
spread = vector.new(512,512,1024),
|
||||
seed = -1914,
|
||||
octaves = 1,
|
||||
persistence = 1,
|
||||
}, true)
|
||||
minetest.set_mapgen_setting("mgvalleys_altitude_chill", 90)
|
||||
minetest.set_mapgen_setting_noiseparams("mgvalleys_np_valley_profile", {
|
||||
flags = "defaults",
|
||||
lacunarity = 2,
|
||||
offset = 0.6,
|
||||
scale = 0.5,
|
||||
spread = vector.new(64,2048,1024),
|
||||
seed = 777,
|
||||
octaves = 1,
|
||||
persistence = 1,
|
||||
}, true)
|
||||
--mgvalleys_large_cave_depth = -33
|
||||
--mgvalleys_massive_cave_depth = -256
|
||||
minetest.set_mapgen_setting("mgvalleys_river_depth", 0, true)
|
||||
|
||||
-- This ensures both that caverns are appropriately hard to reach and that they won't be reached on a large scale by oceans.
|
||||
minetest.set_mapgen_setting("mgvalleys_cavern_limit", -1400, true)
|
||||
|
||||
|
|
@ -40,7 +40,7 @@ rgt.register_node("stone_tile", {
|
|||
rgt.register_node("cobble", {
|
||||
tiles = {"rgt_cobble.png"},
|
||||
_variants = "all",
|
||||
groups = {dig_immediate = 3}
|
||||
groups = {stone = 1}
|
||||
})
|
||||
|
||||
rgt.register_node("dirt", {
|
||||
|
|
@ -54,11 +54,122 @@ rgt.register_node("dirt_mossy", {
|
|||
})
|
||||
|
||||
rgt.register_node("dirt_grass", {
|
||||
tiles = {"rgt_grass_top.png", "rgt_dirt.png", "rgt_dirt.png^rgt_grass_side.png"},
|
||||
paramtype2 = "color",
|
||||
tiles = {"rgt_grass_top.png", {name = "rgt_dirt.png", color = "#fff"}, {name = "rgt_dirt.png^rgt_grass_side_shadow.png", color = "#fff"}},
|
||||
overlay_tiles = {"", "", "rgt_grass_side.png"},
|
||||
palette = "rgt_palette_grass.png",
|
||||
on_construct = function(pos)
|
||||
|
||||
end,
|
||||
-- tiles = {"[fill:16x16:0,0:#3e7e7b^[fill:14x14:1,1:#326764"},
|
||||
groups = {dig_immediate = 3}
|
||||
})
|
||||
|
||||
-- Grass
|
||||
for i = 1, 3 do
|
||||
rgt.register_node("grass_"..i, {
|
||||
drawtype = "plantlike",
|
||||
paramtype = "light",
|
||||
paramtype2 = "meshoptions",
|
||||
place_param2 = 2,
|
||||
sunlight_propagates = false,
|
||||
tiles = {"rgt_grass_"..i..".png"},
|
||||
groups = {attached_node = 3, dig_immediate = 3},
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
-6/16, -0.5, -6/16,
|
||||
6/16, 6/16, 6/16
|
||||
}
|
||||
}
|
||||
})
|
||||
end
|
||||
|
||||
-- Tall grass
|
||||
rgt.register_node("grass_tall_bottom", {
|
||||
drawtype = "plantlike",
|
||||
paramtype = "light",
|
||||
paramtype2 = "meshoptions",
|
||||
place_param2 = 2,
|
||||
sunlight_propagates = false,
|
||||
tiles = {"rgt_grass_tall.png^[verticalframe:2:1"},
|
||||
groups = {attached_node = 3, dig_immediate = 3},
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
-6/16, -0.5, -6/16,
|
||||
6/16, 0.5, 6/16
|
||||
}
|
||||
},
|
||||
node_placement_prediction = "",
|
||||
after_destruct = function(pos)
|
||||
local above = pos:offset(0, 1, 0)
|
||||
local na = minetest.get_node(above)
|
||||
if na.name:find "grass_tall_top" then
|
||||
minetest.remove_node(above)
|
||||
end
|
||||
end,
|
||||
on_place = function(s, p, pt)
|
||||
if pt.type ~= "node" then return end
|
||||
|
||||
local target = pt.above
|
||||
|
||||
if not minetest.get_node(target:offset(0, -1, 0)).name:find "dirt_grass" then
|
||||
return
|
||||
end
|
||||
|
||||
local above = target:offset(0, 1, 0)
|
||||
if minetest.get_node(above).name == "air" then
|
||||
minetest.set_node(target, {name = "grass_tall_bottom", param2 = 2})
|
||||
minetest.set_node(above, {name = "grass_tall_top", param2 = 2})
|
||||
s:take_item()
|
||||
return s
|
||||
end
|
||||
end
|
||||
})
|
||||
|
||||
rgt.register_node("grass_tall_top", {
|
||||
drawtype = "plantlike",
|
||||
paramtype = "light",
|
||||
paramtype2 = "meshoptions",
|
||||
place_param2 = 2,
|
||||
sunlight_propagates = false,
|
||||
tiles = {"rgt_grass_tall.png^[verticalframe:2:0"},
|
||||
groups = {dig_immediate = 3},
|
||||
walkable = false,
|
||||
selection_box = {
|
||||
type = "fixed",
|
||||
fixed = {
|
||||
-6/16, -0.5, -6/16,
|
||||
6/16, 6/16, 6/16
|
||||
}
|
||||
},
|
||||
drop = "grass_tall_bottom",
|
||||
after_destruct = function(pos)
|
||||
local below = pos:offset(0, -1, 0)
|
||||
local nb = minetest.get_node(below)
|
||||
if nb.name:find "grass_tall_bottom" then
|
||||
minetest.remove_node(below)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
||||
-- TODO: Tall grass
|
||||
--rgt.register_node("tall_grass", {
|
||||
-- drawtype = "mesh",
|
||||
-- mesh = "rgt_plantlike_1x1x2.obj",
|
||||
-- use_texture_alpha = "clip",
|
||||
-- paramtype = "light",
|
||||
-- sunlight_propagates = false,
|
||||
-- tiles = {"rgt_grass_tall.png"},
|
||||
-- groups = {dig_immediate = 3},
|
||||
-- walkable = false
|
||||
--})
|
||||
|
||||
|
||||
|
||||
rgt.register_node("path_grass", {
|
||||
drawtype = "nodebox",
|
||||
node_box = {
|
||||
|
|
@ -91,43 +202,43 @@ rgt.register_node("oak_leaves", {
|
|||
drawtype = "allfaces",
|
||||
tiles = {"rgt_oak_leaves.png"},
|
||||
use_texture_alpha = "clip",
|
||||
groups = {dig_immediate = 3}
|
||||
groups = {dig_immediate = 3},
|
||||
})
|
||||
|
||||
rgt.register_node("oak_planks", {
|
||||
tiles = {{name = "rgt_oak_planks.png", align_style = "world"}},
|
||||
_variants = "all",
|
||||
groups = {dig_immediate = 3}
|
||||
groups = {dig_immediate = 3},
|
||||
})
|
||||
|
||||
rgt.register_node("dark_planks", {
|
||||
tiles = {{name = "rgt_dark_planks.png", align_style = "world"}},
|
||||
_variants = "all",
|
||||
groups = {dig_immediate = 3}
|
||||
groups = {dig_immediate = 3},
|
||||
})
|
||||
|
||||
rgt.register_node("spruce_planks", {
|
||||
tiles = {{name = "rgt_spruce_planks.png", align_style = "world"}},
|
||||
_variants = "all",
|
||||
groups = {dig_immediate = 3}
|
||||
groups = {dig_immediate = 3},
|
||||
})
|
||||
|
||||
rgt.register_node("acacia_planks", {
|
||||
tiles = {{name = "rgt_acacia_planks.png", align_style = "world"}},
|
||||
_variants = "all",
|
||||
groups = {dig_immediate = 3}
|
||||
groups = {dig_immediate = 3},
|
||||
})
|
||||
|
||||
rgt.register_node("redwood_planks", {
|
||||
tiles = {{name = "rgt_redwood_planks.png", align_style = "world"}},
|
||||
_variants = "all",
|
||||
groups = {dig_immediate = 3}
|
||||
groups = {dig_immediate = 3},
|
||||
})
|
||||
|
||||
rgt.register_node("birch_planks", {
|
||||
tiles = {{name = "rgt_birch_planks.png", align_style = "world"}},
|
||||
_variants = "all",
|
||||
groups = {dig_immediate = 3}
|
||||
groups = {dig_immediate = 3},
|
||||
})
|
||||
|
||||
|
||||
|
|
@ -149,6 +260,13 @@ rgt.register_node("glass", {
|
|||
--}
|
||||
|
||||
|
||||
rgt.register_node("basalt", {
|
||||
tiles = {{name = "rgt_basalt.png", align_style = "world"}},
|
||||
_variants = "all",
|
||||
groups = {dig_immediate = 3},
|
||||
})
|
||||
|
||||
|
||||
rgt.register_node("water", {
|
||||
tiles = {"[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33"},
|
||||
groups = {dig_immediate = 3},
|
||||
|
|
@ -158,6 +276,7 @@ rgt.register_node("water", {
|
|||
walkable = false,
|
||||
climbable = true,
|
||||
post_effect_color = "#2d5a7c55",
|
||||
is_ground_content = false,
|
||||
|
||||
liquidtype = "source",
|
||||
-- Minetest pro tip: Do not try to use aliases for these.
|
||||
|
|
@ -178,6 +297,7 @@ rgt.register_node("water_flowing", {
|
|||
walkable = false,
|
||||
climbable = true,
|
||||
post_effect_color = "#2d5a7c55",
|
||||
is_ground_content = false,
|
||||
|
||||
liquidtype = "flowing",
|
||||
liquid_alternative_source = "red_glazed_terracotta:water",
|
||||
|
|
@ -230,6 +350,35 @@ minetest.register_alias("mapgen_water_source", "red_glazed_terracotta:water")
|
|||
minetest.register_alias("mapgen_river_water_source", "red_glazed_terracotta:river_water")
|
||||
|
||||
|
||||
--[[
|
||||
|
||||
Biomes to add:
|
||||
|
||||
[Temperate]
|
||||
Steppe
|
||||
Moor
|
||||
Plains
|
||||
Light Deciduous Forest
|
||||
Dark Deciduous Forest
|
||||
|
||||
[Cold]
|
||||
Alpine
|
||||
Glacier
|
||||
Taiga
|
||||
Tundra
|
||||
Coniferous Forest
|
||||
|
||||
[Warm]
|
||||
Desert
|
||||
Badlands
|
||||
Jungle
|
||||
Swamp
|
||||
Marsh
|
||||
|
||||
--]]
|
||||
|
||||
include "biomes.lua"
|
||||
|
||||
|
||||
rgt.register_node("light", {
|
||||
tiles = {"[fill:1x1:0,0:#fed"},
|
||||
|
|
@ -247,62 +396,80 @@ minetest.register_ore {
|
|||
clust_size = 1
|
||||
}
|
||||
|
||||
|
||||
--minetest.register_decoration {
|
||||
-- deco_type = "schematic",
|
||||
-- place_on = "dirt_grass",
|
||||
-- biomes = {"forest"},
|
||||
-- y_min = 1,
|
||||
-- fill_ratio = 0.01,
|
||||
-- schematic = minetest.get_modpath(minetest.get_current_modname()).."/schems/tree.mts",
|
||||
-- flags = "place_center_x, place_center_z",
|
||||
-- place_offset_y = 1,
|
||||
--}
|
||||
|
||||
minetest.register_biome{
|
||||
name = "plains",
|
||||
|
||||
node_top = "dirt_grass",
|
||||
depth_top = 1,
|
||||
|
||||
node_filler = "dirt",
|
||||
depth_filler = 5,
|
||||
|
||||
node_riverbed = "dirt",
|
||||
depth_riverbed = 3,
|
||||
|
||||
node_dungeon = "cobble",
|
||||
node_dungeon_alt = "stone_brick_large",
|
||||
|
||||
|
||||
y_max = 3000,
|
||||
y_min = 2,
|
||||
vertical_blend = 2,
|
||||
|
||||
heat_point = 50,
|
||||
humidity_point = 50,
|
||||
minetest.register_decoration {
|
||||
deco_type = "schematic",
|
||||
place_on = "dirt_grass",
|
||||
biomes = {"forest"},
|
||||
y_min = 1,
|
||||
y_max = 8000,
|
||||
fill_ratio = 0.01,
|
||||
schematic = minetest.get_modpath(minetest.get_current_modname()).."/schems/tree.mts",
|
||||
flags = "place_center_x, place_center_z",
|
||||
place_offset_y = 1,
|
||||
}
|
||||
|
||||
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_brick_large",
|
||||
|
||||
|
||||
y_max = 1,
|
||||
y_min = -3,
|
||||
vertical_blend = 1,
|
||||
|
||||
heat_point = 50,
|
||||
humidity_point = 50,
|
||||
minetest.register_decoration {
|
||||
deco_type = "schematic",
|
||||
place_on = "dirt_grass",
|
||||
biomes = {"plains"},
|
||||
y_min = 1,
|
||||
noise_params = {
|
||||
offset = 0,
|
||||
scale = 0.25,
|
||||
spread = {x = 8, y = 8, z = 8},
|
||||
seed = 3456789,
|
||||
octaves = 4,
|
||||
persist = 0.6,
|
||||
lacunarity = 3,
|
||||
},
|
||||
-- fill_ratio = 0.1,
|
||||
schematic = {
|
||||
size = {x = 1, y = 2, z = 1}, -- 1×2×1
|
||||
data = {
|
||||
{name = "grass_tall_bottom", prob = 255, param2 = 2},
|
||||
{name = "grass_tall_top", prob = 255, param2 = 2},
|
||||
},
|
||||
},
|
||||
place_offset_y = 1,
|
||||
}
|
||||
|
||||
minetest.register_decoration {
|
||||
deco_type = "simple",
|
||||
place_on = "dirt_grass",
|
||||
biomes = {"forest", "plains"},
|
||||
decoration = {"grass_1", "grass_2", "grass_3"},
|
||||
param2 = 2,
|
||||
y_min = 1,
|
||||
fill_ratio = 0.2,
|
||||
}
|
||||
|
||||
minetest.override_item("", {
|
||||
on_place = function(s, p, pt)
|
||||
if minetest.get_node(pt.under).name:find "dirt_grass" then
|
||||
minetest.set_node(pt.under, {name = "path_grass"})
|
||||
end
|
||||
-- minetest.spawn_tree(pt.above, {
|
||||
-- axiom = "TF[FFA]",
|
||||
-- rules_a = "F",
|
||||
-- trunk = "oak_log",
|
||||
-- leaves = "oak_leaves",
|
||||
-- angle = 30,
|
||||
-- iterations = 2,
|
||||
-- random_level = 0,
|
||||
-- trunk_type = "single",
|
||||
---- thin_branches = true,
|
||||
-- fruit_chance = 0,
|
||||
-- fruit = "stone_brick"
|
||||
-- })
|
||||
end
|
||||
})
|
||||
|
||||
minetest.register_chatcommand("biome", {
|
||||
func = function(name)
|
||||
tell(name, minetest.get_biome_name(minetest.get_biome_data(minetest.get_player_by_name(name):get_pos()).biome))
|
||||
end
|
||||
})
|
||||
|
||||
include "config.lua"
|
||||
|
||||
--minetest.register_mapgen_script(minetest.get_modpath(minetest.get_current_modname()).."/mapgen.lua")
|
||||
|
|
|
|||
14
mods/rgt_world/mapgen.lua
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
local c = minetest.get_content_id
|
||||
|
||||
local c_stone = c "stone"
|
||||
|
||||
local np_continental = {
|
||||
offset = 0,
|
||||
scale = 1,
|
||||
spread = {x = 4096, y = 4096, z = 4096},
|
||||
seed = 12345,
|
||||
octaves = 4,
|
||||
persist = 0.6
|
||||
}
|
||||
local n_terrain = {}
|
||||
BIN
mods/rgt_world/textures/rgt_basalt.png
Normal file
|
After Width: | Height: | Size: 217 B |
|
Before Width: | Height: | Size: 440 B After Width: | Height: | Size: 450 B |
BIN
mods/rgt_world/textures/rgt_grass_1.png
Normal file
|
After Width: | Height: | Size: 314 B |
BIN
mods/rgt_world/textures/rgt_grass_2.png
Normal file
|
After Width: | Height: | Size: 184 B |
BIN
mods/rgt_world/textures/rgt_grass_3.png
Normal file
|
After Width: | Height: | Size: 230 B |
|
Before Width: | Height: | Size: 399 B After Width: | Height: | Size: 338 B |
BIN
mods/rgt_world/textures/rgt_grass_side_shadow.png
Normal file
|
After Width: | Height: | Size: 161 B |
BIN
mods/rgt_world/textures/rgt_grass_tall.png
Normal file
|
After Width: | Height: | Size: 387 B |
|
Before Width: | Height: | Size: 354 B After Width: | Height: | Size: 302 B |
BIN
mods/rgt_world/textures/rgt_modern_floor.png
Normal file
|
After Width: | Height: | Size: 217 B |
BIN
mods/rgt_world/textures/rgt_palette_grass.png
Normal file
|
After Width: | Height: | Size: 95 B |
|
|
@ -11,7 +11,8 @@ function ns.register_slab(def)
|
|||
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir"
|
||||
paramtype2 = "facedir",
|
||||
_variant = "slab"
|
||||
}))
|
||||
end
|
||||
|
||||
|
|
@ -61,7 +62,8 @@ function ns.register_stair(def)
|
|||
fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, -0.5, 0, 0.5, 0.5, 0.5}}
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir"
|
||||
paramtype2 = "facedir",
|
||||
_variant = "stair",
|
||||
}))
|
||||
|
||||
rgt.register_node(def._name.."_stair_inner", extend(table.copy(def), {
|
||||
|
|
@ -71,7 +73,8 @@ function ns.register_stair(def)
|
|||
fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, -0.5, 0, 0.5, 0.5, 0.5}, {-0.5, -0.5, -0.5, 0, 0.5, 0.5}}
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir"
|
||||
paramtype2 = "facedir",
|
||||
_variant = "stair_inner",
|
||||
}))
|
||||
|
||||
rgt.register_node(def._name.."_stair_outer", extend(def, {
|
||||
|
|
@ -81,7 +84,8 @@ function ns.register_stair(def)
|
|||
fixed = {{-0.5, -0.5, -0.5, 0.5, 0, 0.5}, {-0.5, -0.5, 0.5, 0, 0.5, 0}}
|
||||
},
|
||||
paramtype = "light",
|
||||
paramtype2 = "facedir"
|
||||
paramtype2 = "facedir",
|
||||
_variant = "stair_outer",
|
||||
}))
|
||||
end
|
||||
|
||||
|
|
|
|||