Update
This commit is contained in:
parent
db2139f7ba
commit
18ff69274f
14 changed files with 565 additions and 11 deletions
|
|
@ -40,11 +40,21 @@ rgt = {}
|
||||||
local ns = rgt
|
local ns = rgt
|
||||||
|
|
||||||
function ns.register_node(name, def)
|
function ns.register_node(name, def)
|
||||||
|
def._name = name
|
||||||
local alias
|
local alias
|
||||||
if not name:find(":") then
|
if not name:find(":") then
|
||||||
alias = name
|
alias = name
|
||||||
name = "red_glazed_terracotta:"..name
|
name = "red_glazed_terracotta:"..name
|
||||||
end
|
end
|
||||||
|
if def._variants then
|
||||||
|
if type(def._variants) == "string" then
|
||||||
|
rgt_world["register_"..def._variants](def)
|
||||||
|
else
|
||||||
|
for _, x in ipairs(def._variants) do
|
||||||
|
rgt_world["register_"..x](def)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
minetest.register_node(":"..name, def)
|
minetest.register_node(":"..name, def)
|
||||||
if alias then
|
if alias then
|
||||||
minetest.register_alias(alias, name)
|
minetest.register_alias(alias, name)
|
||||||
|
|
|
||||||
146
mods/rgt_outback/init.lua
Normal file
146
mods/rgt_outback/init.lua
Normal file
|
|
@ -0,0 +1,146 @@
|
||||||
|
|
||||||
|
local REALM_START = 5000
|
||||||
|
local REALM_END = 5500
|
||||||
|
|
||||||
|
rgt_realms.register_realm {
|
||||||
|
name = "outback",
|
||||||
|
label = "Outback",
|
||||||
|
min = vector.new(-100, REALM_START, -100),
|
||||||
|
max = vector.new(100, REALM_END, 100),
|
||||||
|
sky = {
|
||||||
|
type = "regular",
|
||||||
|
sky_color = {
|
||||||
|
day_sky = "#746ec9",
|
||||||
|
day_horizon = "#94a3ce"
|
||||||
|
},
|
||||||
|
-- fog = {
|
||||||
|
-- fog_distance = 20,
|
||||||
|
-- fog_start = 0.3,
|
||||||
|
-- fog_color = "#aab"
|
||||||
|
-- }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
local vm_data = {}
|
||||||
|
function rgt.add_tree(pos)
|
||||||
|
local vm = minetest.get_voxel_manip(pos:offset(-50, -50, -50), pos:offset(50, 50, 50))
|
||||||
|
local area = VoxelArea(vm:get_emerged_area())
|
||||||
|
vm:get_data(vm_data)
|
||||||
|
local c_air = minetest.get_content_id("air")
|
||||||
|
local c_grass = minetest.get_content_id("dirt_grass")
|
||||||
|
local c_wood = minetest.get_content_id("spruce_planks")
|
||||||
|
local c_root = minetest.get_content_id("path_grass")
|
||||||
|
local up = vector.new(0,1,0)
|
||||||
|
|
||||||
|
|
||||||
|
local tree_radius = math.random(2, 4)
|
||||||
|
local canopy_height = math.random(15, 25)
|
||||||
|
local offset = vector.zero()
|
||||||
|
|
||||||
|
-- local trunk_height = math.random(8, 15) -- Random height for variety
|
||||||
|
-- local initial_radius = math.random(2, 4) * 0.5 -- Start wider (0.5 for smoother scaling)
|
||||||
|
-- local sway_strength = 0.3 -- Max sway offset per height unit
|
||||||
|
--
|
||||||
|
-- local trunk_path = {}
|
||||||
|
-- local current_pos = vector.new(pos.x, pos.y, pos.z)
|
||||||
|
-- local target_pos = vector.new(
|
||||||
|
-- pos.x + (math.random() - 0.5) * 4, -- Slight random lean
|
||||||
|
-- pos.y + trunk_height,
|
||||||
|
-- pos.z + (math.random() - 0.5) * 4
|
||||||
|
-- )
|
||||||
|
-- for h = 0, trunk_height, 0.5 do -- Finer steps for smoothness
|
||||||
|
-- local t = h / trunk_height
|
||||||
|
-- local noise_x = (math.random() - 0.5) * sway_strength * 2 -- Perlin-like noise
|
||||||
|
-- local noise_z = (math.random() - 0.5) * sway_strength * 2
|
||||||
|
-- local path_pos = current_pos + (target_pos - current_pos):normalize() * 0.5 -- Step along axis
|
||||||
|
-- path_pos.x = path_pos.x + noise_x
|
||||||
|
-- path_pos.z = path_pos.z + noise_z
|
||||||
|
-- table.insert(trunk_path, {pos = path_pos, radius = initial_radius * math.sqrt(1 - t)}) -- Exponential taper
|
||||||
|
-- end
|
||||||
|
--
|
||||||
|
-- -- Place trunk nodes along path (interpolate between path points for density)
|
||||||
|
-- for i = 1, #trunk_path - 1 do
|
||||||
|
-- local seg_start = trunk_path[i]
|
||||||
|
-- local seg_end = trunk_path[i+1]
|
||||||
|
-- local seg_len = vector.distance(seg_start.pos, seg_end.pos)
|
||||||
|
-- for step = 0, seg_len, 1 do -- Place at integer positions
|
||||||
|
-- local interp_t = step / seg_len
|
||||||
|
-- local trunk_node = {
|
||||||
|
-- pos = seg_start.pos + (seg_end.pos - seg_start.pos) * interp_t,
|
||||||
|
-- radius = seg_start.radius + (seg_end.radius - seg_start.radius) * interp_t
|
||||||
|
-- }
|
||||||
|
-- local node_x, node_y, node_z = math.round(trunk_node.pos.x), math.round(trunk_node.pos.y), math.round(trunk_node.pos.z)
|
||||||
|
-- local r = math.floor(trunk_node.radius + 0.5) -- Round for voxel placement
|
||||||
|
-- for dx = -r, r do
|
||||||
|
-- for dz = -r, r do
|
||||||
|
-- local dist = vector.distance(vector.new(dx, 0, dz), vector.zero())
|
||||||
|
-- if dist <= r then
|
||||||
|
-- local idx = area:index(node_x + dx, node_y, node_z + dz)
|
||||||
|
-- if vm_data[idx] == c_air then -- Only overwrite air
|
||||||
|
-- vm_data[idx] = c_wood
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- Generate the trunk.
|
||||||
|
local r = tree_radius
|
||||||
|
local p = pos
|
||||||
|
for y = 0, canopy_height do
|
||||||
|
for x = -r, r do
|
||||||
|
for z = -r, r do
|
||||||
|
if vector.distance(vector.new(x, 0, z), vector.zero()) <= r then
|
||||||
|
vm_data[area:index(math.round(p.x +x), math.round(p.y), math.round(p.z +z))] = c_wood
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
p = p:offset(0,1,0) --+vector.rotate_around_axis(vector.new(0,0,0.2), up, math.pi *2 *(math.random() -0.5))
|
||||||
|
end
|
||||||
|
|
||||||
|
--Generate roots.
|
||||||
|
local num_roots = math.random(3, 6) +math.floor(math.abs(tree_radius -3) ^2)
|
||||||
|
for i = 1, num_roots do
|
||||||
|
local dir = vector.rotate_around_axis(vector.new(0,0,1), up, math.pi *2 /num_roots *i)
|
||||||
|
local length = math.random() *6 +3
|
||||||
|
p = pos +(dir *math.floor(tree_radius +1))
|
||||||
|
while length > 0 do
|
||||||
|
local pr = p:round()
|
||||||
|
-- Check up to 3 nodes down for grass.
|
||||||
|
for j = 1, 3 do
|
||||||
|
if vm_data[area:index(pr.x, pr.y, pr.z)] ~= c_air then break end
|
||||||
|
p.y = p.y -1
|
||||||
|
pr.y = pr.y -1
|
||||||
|
end
|
||||||
|
-- End the root if it would be too vertical.
|
||||||
|
if vm_data[area:index(pr.x, pr.y, pr.z)] == c_air then break end
|
||||||
|
vm_data[area:index(pr.x, pr.y, pr.z)] = c_root
|
||||||
|
length = length -1
|
||||||
|
-- Randomly nudge the root direction.
|
||||||
|
-- dir = dir:rotate_around_axis(up, math.random() *1.5 -0.5)
|
||||||
|
p = p +dir:rotate_around_axis(up, math.random() *1.5 -0.5)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
vm:set_data(vm_data)
|
||||||
|
vm:write_to_map()
|
||||||
|
end
|
||||||
|
|
||||||
|
rgt.register_node("tree", {
|
||||||
|
on_place = function(s, p, pt)
|
||||||
|
--rgt.add_tree(pt.above)
|
||||||
|
minetest.spawn_tree(pt.above, {
|
||||||
|
axiom = "TTTTTT",
|
||||||
|
trunk = "spruce_planks",
|
||||||
|
leaves = "oak_planks"
|
||||||
|
})
|
||||||
|
end
|
||||||
|
})
|
||||||
|
|
||||||
|
rgt.register_node("outback_planks", {
|
||||||
|
tiles = {"rgt_outback_planks.png"},
|
||||||
|
groups = {hand_breakable = 3}
|
||||||
|
})
|
||||||
|
|
||||||
|
minetest.register_mapgen_script(minetest.get_modpath(minetest.get_current_modname()).."/mapgen.lua")
|
||||||
208
mods/rgt_outback/mapgen.lua
Normal file
208
mods/rgt_outback/mapgen.lua
Normal file
|
|
@ -0,0 +1,208 @@
|
||||||
|
|
||||||
|
local REALM_START = vector.new(-100, 5000, -100)
|
||||||
|
local REALM_END = vector.new(100, 5500, 100)
|
||||||
|
|
||||||
|
local vm_data = {}
|
||||||
|
local area
|
||||||
|
|
||||||
|
local function intersection(min, max, b, c)
|
||||||
|
return min.x < c.x and max.x > b.x and
|
||||||
|
min.y < c.y and max.y > b.y and
|
||||||
|
min.z < c.z and max.z > b.z
|
||||||
|
end
|
||||||
|
|
||||||
|
local c_air = minetest.get_content_id("air")
|
||||||
|
|
||||||
|
local c_stone = minetest.get_content_id("stone")
|
||||||
|
local c_dirt = minetest.get_content_id("dirt")
|
||||||
|
local c_grass = minetest.get_content_id("dirt_grass")
|
||||||
|
|
||||||
|
local c_planks = minetest.get_content_id("outback_planks")
|
||||||
|
local c_wood = c_planks
|
||||||
|
local c_leaves = c_stone
|
||||||
|
|
||||||
|
|
||||||
|
local np_terrain = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 1, -- Small height variation
|
||||||
|
spread = {x = 64, y = 64, z = 64},
|
||||||
|
seed = 12345,
|
||||||
|
octaves = 4,
|
||||||
|
persist = 0.6
|
||||||
|
}
|
||||||
|
local n_terrain = {}
|
||||||
|
|
||||||
|
local np_trees = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 1, -- Small height variation
|
||||||
|
spread = {x = 64, y = 64, z = 64},
|
||||||
|
seed = 24521,
|
||||||
|
octaves = 4,
|
||||||
|
persist = 0.6
|
||||||
|
}
|
||||||
|
local n_trees = {}
|
||||||
|
|
||||||
|
|
||||||
|
local np_canopy = {
|
||||||
|
offset = 0,
|
||||||
|
scale = 0.5,
|
||||||
|
spread = {x=16, y=16, z=16},
|
||||||
|
seed = 91527, -- Different seed for variety
|
||||||
|
octaves = 2,
|
||||||
|
persist = 0.5
|
||||||
|
}
|
||||||
|
local n_canopy = {} -- Buffer for 3D noise; generate once per chunk if needed
|
||||||
|
|
||||||
|
local function generate_tree(min, max, base_x, base_y, base_z)
|
||||||
|
-- Randomize tree "type" for variation
|
||||||
|
local tree_type = math.random() -- 0-1
|
||||||
|
local trunk_height = math.floor(8 + tree_type * 7) -- 8-15 tall
|
||||||
|
local canopy_radius = 3 + math.floor(tree_type * 2) -- 3-5 wide
|
||||||
|
local trunk_width = 1 + (tree_type > 0.7 and 1 or 0) -- Mostly 1-wide, sometimes 2
|
||||||
|
|
||||||
|
local top_y = base_y + trunk_height
|
||||||
|
|
||||||
|
-- 1. Roots: Flared base, 2-3 deep, random protrusions
|
||||||
|
local root_depth = 2 + math.random(1)
|
||||||
|
for dy = -root_depth, 0 do
|
||||||
|
local radius_sq = (dy == 0 and 2 or 1)^2 -- Wider at surface
|
||||||
|
for dx = -2, 2 do
|
||||||
|
for dz = -2, 2 do
|
||||||
|
local dist_sq = dx*dx + dz*dz
|
||||||
|
if dist_sq <= radius_sq and math.random() > 0.6 then -- ~40% fill for irregularity
|
||||||
|
local py = base_y + dy
|
||||||
|
if py >= min.y and py <= max.y then -- Bounds check
|
||||||
|
local vi = area:index(base_x + dx, py, base_z + dz)
|
||||||
|
-- Only set if it's grass/dirt (don't overwrite stone)
|
||||||
|
if vm_data[vi] == c_grass or vm_data[vi] == c_dirt then
|
||||||
|
vm_data[vi] = c_wood
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 2. Trunk: Vertical core, optional width
|
||||||
|
for py = base_y, top_y do
|
||||||
|
if py >= min.y and py <= max.y then
|
||||||
|
-- Central trunk
|
||||||
|
local trunk_vi = area:index(base_x, py, base_z)
|
||||||
|
vm_data[trunk_vi] = c_wood
|
||||||
|
|
||||||
|
-- Optional side for width (3-4 effective with roots)
|
||||||
|
if trunk_width == 2 and math.random() > 0.5 then
|
||||||
|
local side_dx = (math.random() > 0.5 and 1 or -1)
|
||||||
|
local side_dz = (math.random() > 0.5 and 1 or -1)
|
||||||
|
local side_vi = area:index(base_x + side_dx, py, base_z + side_dz)
|
||||||
|
vm_data[side_vi] = c_wood
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 3. Canopy: Irregular spreading blob
|
||||||
|
-- Simple 3D loop for ellipsoid; modulate with noise for gaps/branches
|
||||||
|
local canopy_sides3d = {x = max.x - min.x + 1, y = max.y - min.y + 1, z = max.z - min.z + 1}
|
||||||
|
-- local canopy_map = minetest.get_perlin_map(np_canopy, canopy_sides3d)
|
||||||
|
local canopy_noise = minetest.get_perlin_map(np_canopy, canopy_sides3d)
|
||||||
|
canopy_noise:get_3d_map_flat({x=base_x, y=base_y, z=base_z}, n_canopy) -- Sample at base
|
||||||
|
local noise_val = n_canopy[1]
|
||||||
|
|
||||||
|
for dy = -2, canopy_radius do -- Vertical spread
|
||||||
|
local py = top_y + dy - 1 -- Start 1 below top, extend up/down
|
||||||
|
if py >= min.y and py <= max.y then
|
||||||
|
local y_scale = 1 - math.abs(dy) / canopy_radius -- Taper vertically
|
||||||
|
local horiz_radius = math.floor(canopy_radius * y_scale * (0.7 + noise_val * 0.3)) -- Noise variation
|
||||||
|
|
||||||
|
for dx = -canopy_radius, canopy_radius do
|
||||||
|
for dz = -canopy_radius, canopy_radius do
|
||||||
|
local dist_sq = dx*dx + dz*dz
|
||||||
|
local required_radius_sq = horiz_radius * horiz_radius
|
||||||
|
|
||||||
|
if dist_sq <= required_radius_sq then
|
||||||
|
-- Noise for branch-like gaps (lower density = more holes)
|
||||||
|
local branch_noise = (noise_val + math.random(-0.2, 0.2)) * 0.5
|
||||||
|
if math.random() < (0.7 + branch_noise) then -- 50-90% fill
|
||||||
|
local vi = area:index(base_x + dx, py, base_z + dz)
|
||||||
|
-- Overwrite air/grass only
|
||||||
|
-- if vm_data[vi] == 0 or vm_data[vi] == c_grass then -- 0 = air
|
||||||
|
vm_data[vi] = c_leaves
|
||||||
|
-- end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 4. Optional branches: Quick stubs from trunk for extra realism
|
||||||
|
local num_branches = 2 + math.random(3)
|
||||||
|
for i = 1, num_branches do
|
||||||
|
local branch_y = base_y + math.random(4, trunk_height - 2)
|
||||||
|
local branch_len = 1 + math.random(3)
|
||||||
|
local dir_x, dir_z = 0, 0
|
||||||
|
if math.random() > 0.5 then dir_x = (math.random() > 0.5 and 1 or -1) * branch_len
|
||||||
|
else dir_z = (math.random() > 0.5 and 1 or -1) * branch_len end
|
||||||
|
-- Draw line of wood (simple, no Bresenham for perf)
|
||||||
|
for step = 0, branch_len do
|
||||||
|
local px = base_x + math.floor(dir_x * step / branch_len)
|
||||||
|
local pz = base_z + math.floor(dir_z * step / branch_len)
|
||||||
|
local py = branch_y + math.floor((top_y - branch_y) * step / trunk_height * 0.3) -- Slight upward curve
|
||||||
|
local vi = area:index(px, py, pz)
|
||||||
|
if vm_data[vi] == 0 or vm_data[vi] == c_grass then
|
||||||
|
vm_data[vi] = c_wood
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function tree(min, max, x, y, z)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
minetest.register_on_generated(function(vm, min, max)
|
||||||
|
-- Only run for blocks that are part of this realm.
|
||||||
|
if not intersection(min, max, REALM_START, REALM_END) then return end
|
||||||
|
area = VoxelArea(vm:get_emerged_area())
|
||||||
|
vm:get_data(vm_data)
|
||||||
|
|
||||||
|
local sides2d = {x = max.x - min.x + 1, y = max.z - min.z + 1}
|
||||||
|
local terrain = minetest.get_perlin_map(np_terrain, sides2d)
|
||||||
|
terrain:get_2d_map_flat({x = min.x, y = min.z}, n_terrain)
|
||||||
|
|
||||||
|
local trees_map = minetest.get_perlin_map(np_trees, sides2d)
|
||||||
|
trees_map:get_2d_map_flat({x = min.x, y = min.z}, n_trees)
|
||||||
|
|
||||||
|
local trees = {}
|
||||||
|
|
||||||
|
local ni = 1
|
||||||
|
for z = min.z, max.z do
|
||||||
|
for x = min.x, max.x do
|
||||||
|
--Calculate heightmap
|
||||||
|
|
||||||
|
local height = REALM_START.y +100 +(n_terrain[ni] *5)
|
||||||
|
|
||||||
|
for y = min.y, max.y do
|
||||||
|
if y > REALM_START.y and y < REALM_END.y then
|
||||||
|
local vi = area:index(x, y, z)
|
||||||
|
if y < height -1 then
|
||||||
|
vm_data[vi] = c_stone
|
||||||
|
elseif y < height then
|
||||||
|
vm_data[vi] = c_grass
|
||||||
|
elseif y < height +1 and math.random() > 0.98 then
|
||||||
|
trees[#trees +1] = vector.new(x, y, z)
|
||||||
|
else
|
||||||
|
vm_data[vi] = c_air
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
ni = ni +1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
for _, x in pairs(trees) do
|
||||||
|
tree(min, max, x.x, x.y, x.z)
|
||||||
|
end
|
||||||
|
|
||||||
|
vm:set_data(vm_data)
|
||||||
|
end)
|
||||||
2
mods/rgt_outback/mod.conf
Normal file
2
mods/rgt_outback/mod.conf
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
name = rgt_outback
|
||||||
|
depends = rgt_realms
|
||||||
|
|
@ -7,18 +7,57 @@ Player = {
|
||||||
name = p:get_player_name(),
|
name = p:get_player_name(),
|
||||||
object = p
|
object = p
|
||||||
}, {__index = Player})
|
}, {__index = Player})
|
||||||
|
|
||||||
|
local inv = p:get_inventory()
|
||||||
|
inv:set_size("hand", 1)
|
||||||
|
inv:set_stack("hand", 1, ItemStack("red_glazed_terracotta:hand"))
|
||||||
|
e:set_hotbar_size(8)
|
||||||
|
|
||||||
|
p:hud_add {
|
||||||
|
type = "statbar",
|
||||||
|
position = {x=0.5,y=1},
|
||||||
|
offset = {x=10,y=-96},
|
||||||
|
scale = {x=4,y=4},
|
||||||
|
alignment = {x=-1, y=-1},
|
||||||
|
size = {x=27,y=27},
|
||||||
|
text = "rgt_pumpkin.png",
|
||||||
|
number = 20,
|
||||||
|
item = 20,
|
||||||
|
text2 = "rgt_pumpkin_empty.png"
|
||||||
|
}
|
||||||
|
|
||||||
return e
|
return e
|
||||||
|
end,
|
||||||
|
set_hotbar_size = function(m, slots)
|
||||||
|
local p = m.object
|
||||||
|
p:hud_set_hotbar_itemcount(slots)
|
||||||
|
local list = ""
|
||||||
|
for i = 0, slots do
|
||||||
|
list = list..":"..(21*i)..",0=rgt_hotbar.png"
|
||||||
|
end
|
||||||
|
p:hud_set_hotbar_image("[combine:"..(21 *slots +1).."x22"..list)
|
||||||
|
p:hud_set_hotbar_selected_image("rgt_hotbar_selected.png")
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
setmetatable(Player, {
|
setmetatable(Player, {
|
||||||
__call = function(_, ...) return Player.new(...) end
|
__call = function(_, ...) return Player.new(...) end
|
||||||
})
|
})
|
||||||
|
|
||||||
|
minetest.register_craftitem(":red_glazed_terracotta:hand", {
|
||||||
|
inventory_image = "rgt_dirt.png",
|
||||||
|
tool_capabilities = {
|
||||||
|
groupcaps = {
|
||||||
|
hand_breakable = {times = {[3] = 0.7}, uses = 0, maxlevel = 1}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
minetest.register_alias("hand", "red_glazed_terracotta:hand")
|
||||||
|
|
||||||
-- TODO: Replace builtin health system with custom health system
|
-- TODO: Replace builtin health system with custom health system
|
||||||
minetest.hud_replace_builtin("health", {
|
minetest.hud_replace_builtin("health", {
|
||||||
type = "statbar",
|
type = "statbar",
|
||||||
position = {x=0.5,y=1},
|
position = {x=0.5,y=1},
|
||||||
offset = {x=-27 *10 -1,y=-96},
|
offset = {x=-27 *10 -10,y=-96},
|
||||||
scale = {x=4,y=4},
|
scale = {x=4,y=4},
|
||||||
alignment = {x=-1, y=-1},
|
alignment = {x=-1, y=-1},
|
||||||
size = {x=27,y=27},
|
size = {x=27,y=27},
|
||||||
|
|
|
||||||
43
mods/rgt_realms/init.lua
Normal file
43
mods/rgt_realms/init.lua
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
rgt_realms = {
|
||||||
|
realms = {
|
||||||
|
void = {
|
||||||
|
sky = {
|
||||||
|
type = "plain",
|
||||||
|
base_color = "#000"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
local ns = rgt_realms
|
||||||
|
|
||||||
|
function ns.register_realm(def)
|
||||||
|
ns.realms[def.name] = def
|
||||||
|
end
|
||||||
|
|
||||||
|
function ns.get_realm_at_pos(pos)
|
||||||
|
for name, x in pairs(ns.realms) do
|
||||||
|
if name ~= "void" and vector.in_area(pos, x.min, x.max) then
|
||||||
|
return name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return "void"
|
||||||
|
end
|
||||||
|
|
||||||
|
function ns.update_realm(m)
|
||||||
|
local realm = ns.realms[ns.get_realm_at_pos(m.object:get_pos())]
|
||||||
|
if realm.sky then
|
||||||
|
m.object:set_sky(realm.sky)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function ns.check_position(m)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
minetest.register_chatcommand("realm", {
|
||||||
|
func = function(name, args)
|
||||||
|
minetest.get_player_by_name(name):set_pos(ns.realms["outback"].min +(ns.realms["outback"].max -ns.realms["outback"].min) /2)
|
||||||
|
ns.update_realm(rgt.players[name])
|
||||||
|
end
|
||||||
|
})
|
||||||
2
mods/rgt_realms/mod.conf
Normal file
2
mods/rgt_realms/mod.conf
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
name = rgt_realms
|
||||||
|
depends = rgt_base
|
||||||
|
|
@ -84,7 +84,7 @@ minetest.register_node(":rgt_towns:constructor", {
|
||||||
local m = minetest.get_meta(pos)
|
local m = minetest.get_meta(pos)
|
||||||
local grid = m:get_string("grid")
|
local grid = m:get_string("grid")
|
||||||
local gpos = vector.from_string(m:get_string("build_pos"))
|
local gpos = vector.from_string(m:get_string("build_pos"))
|
||||||
local plot = m:get("plot") or "empty_plot"
|
local plot = m:get("plot") or "house"
|
||||||
|
|
||||||
local inv = m:get_inventory()
|
local inv = m:get_inventory()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,8 +152,14 @@ minetest.register_chatcommand("new_plot", {
|
||||||
|
|
||||||
minetest.register_chatcommand("load_plot", {
|
minetest.register_chatcommand("load_plot", {
|
||||||
func = function(name, args)
|
func = function(name, args)
|
||||||
|
local ws = db:get("workspace:"..name)
|
||||||
|
if ws then
|
||||||
|
ws = minetest.deserialize(ws)
|
||||||
|
else
|
||||||
|
return
|
||||||
|
end
|
||||||
if args and args ~= "" then
|
if args and args ~= "" then
|
||||||
ns.load_plot(name, args)
|
ns.load_plot(ws, args)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,8 @@ rgt_towns.main = {}
|
||||||
ns = rgt_towns.main
|
ns = rgt_towns.main
|
||||||
|
|
||||||
ns.plots = {
|
ns.plots = {
|
||||||
"empty_plot"
|
"empty_plot",
|
||||||
|
"house"
|
||||||
}
|
}
|
||||||
|
|
||||||
rgt_towns.register_spawner {
|
rgt_towns.register_spawner {
|
||||||
|
|
@ -41,3 +42,17 @@ rgt_towns.register_plot{
|
||||||
ground_level = 5,
|
ground_level = 5,
|
||||||
can_build = ns.plots
|
can_build = ns.plots
|
||||||
}
|
}
|
||||||
|
|
||||||
|
rgt_towns.register_plot{
|
||||||
|
name = "house",
|
||||||
|
label = "House",
|
||||||
|
description = "Hello world",
|
||||||
|
schematic = minetest.get_modpath(minetest.get_current_modname()).."/schems/house.mts",
|
||||||
|
recipe = {
|
||||||
|
"oak_planks 1", "oak_planks 1", "oak_planks 1",
|
||||||
|
"oak_log 1", "glass 1", "oak_log 1",
|
||||||
|
"cobble 1", "cobble 1", "cobble 1",
|
||||||
|
},
|
||||||
|
ground_level = 5,
|
||||||
|
can_build = ns.plots
|
||||||
|
}
|
||||||
Binary file not shown.
BIN
mods/rgt_towns/rgt_towns_main/schems/house.mts
Normal file
BIN
mods/rgt_towns/rgt_towns_main/schems/house.mts
Normal file
Binary file not shown.
|
|
@ -1,3 +1,5 @@
|
||||||
|
rgt_world = {}
|
||||||
|
local ns = rgt_world
|
||||||
|
|
||||||
local function rep(tx, size)
|
local function rep(tx, size)
|
||||||
local out = "[combine:"..(size *16).."x"..(size *16)
|
local out = "[combine:"..(size *16).."x"..(size *16)
|
||||||
|
|
@ -9,13 +11,17 @@ local function rep(tx, size)
|
||||||
return out
|
return out
|
||||||
end
|
end
|
||||||
|
|
||||||
|
include "variants.lua"
|
||||||
|
|
||||||
rgt.register_node("stone", {
|
rgt.register_node("stone", {
|
||||||
tiles = {"rgt_stone.png"},
|
tiles = {{name = "rgt_stone.png", align_style = "world"}},
|
||||||
|
_variants = "all",
|
||||||
groups = {dig_immediate = 3}
|
groups = {dig_immediate = 3}
|
||||||
})
|
})
|
||||||
|
|
||||||
rgt.register_node("cobble", {
|
rgt.register_node("cobble", {
|
||||||
tiles = {"rgt_cobble.png"},
|
tiles = {"rgt_cobble.png"},
|
||||||
|
_variants = "all",
|
||||||
groups = {dig_immediate = 3}
|
groups = {dig_immediate = 3}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -48,33 +54,54 @@ rgt.register_node("path_grass", {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
rgt.register_node("oak_log", {
|
||||||
|
tiles = {"rgt_oak_log_top.png", "rgt_oak_log_side.png"},
|
||||||
|
groups = {dig_immediate = 3}
|
||||||
|
})
|
||||||
|
|
||||||
rgt.register_node("oak_planks", {
|
rgt.register_node("oak_planks", {
|
||||||
tiles = {"rgt_oak_planks.png"},
|
tiles = {{name = "rgt_oak_planks.png", align_style = "world"}},
|
||||||
|
_variants = "all",
|
||||||
groups = {dig_immediate = 3}
|
groups = {dig_immediate = 3}
|
||||||
})
|
})
|
||||||
|
|
||||||
rgt.register_node("dark_planks", {
|
rgt.register_node("dark_planks", {
|
||||||
tiles = {"rgt_dark_planks.png"},
|
tiles = {{name = "rgt_dark_planks.png", align_style = "world"}},
|
||||||
|
_variants = "all",
|
||||||
groups = {dig_immediate = 3}
|
groups = {dig_immediate = 3}
|
||||||
})
|
})
|
||||||
|
|
||||||
rgt.register_node("spruce_planks", {
|
rgt.register_node("spruce_planks", {
|
||||||
tiles = {"rgt_spruce_planks.png"},
|
tiles = {{name = "rgt_spruce_planks.png", align_style = "world"}},
|
||||||
|
_variants = "all",
|
||||||
groups = {dig_immediate = 3}
|
groups = {dig_immediate = 3}
|
||||||
})
|
})
|
||||||
|
|
||||||
rgt.register_node("acacia_planks", {
|
rgt.register_node("acacia_planks", {
|
||||||
tiles = {"rgt_acacia_planks.png"},
|
tiles = {{name = "rgt_acacia_planks.png", align_style = "world"}},
|
||||||
|
_variants = "all",
|
||||||
groups = {dig_immediate = 3}
|
groups = {dig_immediate = 3}
|
||||||
})
|
})
|
||||||
|
|
||||||
rgt.register_node("redwood_planks", {
|
rgt.register_node("redwood_planks", {
|
||||||
tiles = {"rgt_redwood_planks.png"},
|
tiles = {{name = "rgt_redwood_planks.png", align_style = "world"}},
|
||||||
|
_variants = "all",
|
||||||
groups = {dig_immediate = 3}
|
groups = {dig_immediate = 3}
|
||||||
})
|
})
|
||||||
|
|
||||||
rgt.register_node("birch_planks", {
|
rgt.register_node("birch_planks", {
|
||||||
tiles = {"rgt_birch_planks.png"},
|
tiles = {{name = "rgt_birch_planks.png", align_style = "world"}},
|
||||||
|
_variants = "all",
|
||||||
|
groups = {dig_immediate = 3}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
rgt.register_node("glass", {
|
||||||
|
drawtype = "glasslike",
|
||||||
|
paramtype = "light",
|
||||||
|
tiles = {{name = "rgt_glass.png", align_style = "world"}},
|
||||||
|
_variants = "all",
|
||||||
groups = {dig_immediate = 3}
|
groups = {dig_immediate = 3}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
||||||
56
mods/rgt_world/variants.lua
Normal file
56
mods/rgt_world/variants.lua
Normal file
|
|
@ -0,0 +1,56 @@
|
||||||
|
local ns = rgt_world
|
||||||
|
|
||||||
|
function ns.register_slab(def)
|
||||||
|
def = table.copy(def)
|
||||||
|
def._variants = nil
|
||||||
|
|
||||||
|
rgt.register_node(def._name.."_slab", extend(def, {
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
fixed = {-0.5, -0.5, -0.5, 0.5, 0, 0.5}
|
||||||
|
},
|
||||||
|
paramtype = "light",
|
||||||
|
paramtype2 = "facedir"
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
function ns.register_stair(def)
|
||||||
|
def = table.copy(def)
|
||||||
|
def._variants = nil
|
||||||
|
|
||||||
|
rgt.register_node(def._name.."_stair", extend(table.copy(def), {
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
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"
|
||||||
|
}))
|
||||||
|
|
||||||
|
rgt.register_node(def._name.."_stair_inner", extend(table.copy(def), {
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
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"
|
||||||
|
}))
|
||||||
|
|
||||||
|
rgt.register_node(def._name.."_stair_outer", extend(def, {
|
||||||
|
drawtype = "nodebox",
|
||||||
|
node_box = {
|
||||||
|
type = "fixed",
|
||||||
|
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"
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
function ns.register_all(def)
|
||||||
|
ns.register_slab(def)
|
||||||
|
ns.register_stair(def)
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue