Add more things

This commit is contained in:
Signal 2025-09-17 01:12:02 -04:00
parent be2262fa17
commit d6662e8094
26 changed files with 565 additions and 26 deletions

View file

@ -0,0 +1,98 @@
rgt_cosmetics = {
characters = {}
}
local ns = rgt_cosmetics
--[[
{
name = "", -- Technical name
label = "", -- Displayed name
texture = "",
scale = 0.88, -- Amount by which to scale visual_size for this character
eye_height = 1.6, -- For use with `scale`
}
]]
function ns.register_character(def)
ns.characters[def.name] = def
end
function ns.set_character(m, chr)
if type(chr) == "string" then
chr = ns.characters[chr]
end
m.object:set_properties {
visual = "mesh",
mesh = "rgt_character.gltf",
textures = {chr.texture},
visual_size = vector.new(1,1,1) *chr.scale,
eye_height = chr.eye_height,
shaded = false,
}
m.object:get_inventory():set_stack("hand", 1, ItemStack("red_glazed_terracotta:_hand_"..chr.name))
end
minetest.register_on_joinplayer(function(p)
local m = rgt.players[p:get_player_name()]
ns.set_character(m, m.object:get_meta():get("character") or "key")
end)
minetest.register_chatcommand("character", {
func = function(name, args)
ns.set_character(rgt.players[name], args)
end
})
local _hand = minetest.registered_items[""]
function rgt.register_hand(name, caps, realname)
rgt.register_node("_hand_"..name, {
description = "",
paramtype = "light",
drawtype = "mesh",
mesh = "rgt_hand.gltf",
tiles = {"rgt_base_"..(realname or name or "placeholder")..".png"},
use_texture_alpha = "opaque",
visual_scale = 1,
wield_scale = vector.new(2,2,2),
node_placement_prediction = "",
on_construct = function(pos)
minetest.remove_node(pos)
end,
drop = "",
on_drop = function()
return ""
end,
range = _hand.range,
pointabilities = caps and caps.pointabilities or {},
tool_capabilities = caps or {
full_punch_interval = 0,
max_drop_level = 0,
groupcaps = {
-- dig_immediate = {times = {0}, uses = 0, maxlevel = 5},
hand_breakable = {times = {0.3, 0.5, 0.7}, uses = 0, maxlevel = 5}
},
damage_groups = {fleshy=1},
},
groups = {not_in_creative_inventory = 1, dig_immediate = 1}
})
end
rgt.register_hand("key")
rgt.register_hand("vix")
-- Builtin characters
ns.register_character {
name = "key",
label = "Key",
texture = "rgt_base_key.png",
scale = 0.88,
eye_height = 1.6
}
ns.register_character {
name = "vix",
label = "Vix",
texture = "rgt_base_vix.png",
scale = 0.8,
eye_height = 1.5
}

View file

@ -0,0 +1,2 @@
name = rgt_cosmetics
depends = rgt_player

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View file

@ -127,20 +127,20 @@ function rgt.add_tree(pos)
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}
})
rgt.register_node("dirt_stony", {
tiles = {"rgt_dirt_stony.png", "rgt_dirt.png"},
groups = {hand_breakable = 3}
})
rgt.register_node("cobble_mossy", {
tiles = {"rgt_cobble_mossy.png"},
groups = {hand_breakable = 3}
})
minetest.register_mapgen_script(minetest.get_modpath(minetest.get_current_modname()).."/mapgen.lua")

View file

@ -14,7 +14,11 @@ end
local c_air = minetest.get_content_id("air")
local c_stone = minetest.get_content_id("stone")
local c_cobble = minetest.get_content_id("cobble")
local c_mossy_cobble = minetest.get_content_id("cobble_mossy")
local c_dirt = minetest.get_content_id("dirt")
local c_stony_dirt = minetest.get_content_id("dirt_stony")
local c_mossy_dirt = minetest.get_content_id("dirt_mossy")
local c_grass = minetest.get_content_id("dirt_grass")
local c_planks = minetest.get_content_id("outback_planks")
@ -32,6 +36,16 @@ local np_terrain = {
}
local n_terrain = {}
local np_surface = {
offset = 0,
scale = 1, -- Small height variation
spread = {x = 4, y = 4, z = 4},
seed = 87745,
octaves = 3 ,
persist = 0.6
}
local n_surface = {}
local np_trees = {
offset = 0,
scale = 1, -- Small height variation
@ -160,6 +174,7 @@ 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
@ -170,6 +185,9 @@ minetest.register_on_generated(function(vm, min, max)
local terrain = minetest.get_perlin_map(np_terrain, sides2d)
terrain:get_2d_map_flat({x = min.x, y = min.z}, n_terrain)
local surface = minetest.get_perlin_map(np_surface, sides2d)
surface:get_2d_map_flat({x = min.x, y = min.z}, n_surface)
local trees_map = minetest.get_perlin_map(np_trees, sides2d)
trees_map:get_2d_map_flat({x = min.x, y = min.z}, n_trees)
@ -188,7 +206,17 @@ minetest.register_on_generated(function(vm, min, max)
if y < height -1 then
vm_data[vi] = c_stone
elseif y < height then
vm_data[vi] = c_grass
if n_surface[ni] > 0.65 then
vm_data[vi] = c_mossy_cobble
elseif n_surface[ni] > 0.3 then
vm_data[vi] = c_cobble
elseif n_surface[ni] > -0.3 then
vm_data[vi] = c_stony_dirt
elseif n_surface[ni] < -0.8 then
vm_data[vi] = c_mossy_dirt
else
vm_data[vi] = c_dirt
end
elseif y < height +1 and math.random() > 0.98 then
trees[#trees +1] = vector.new(x, y, z)
else

Binary file not shown.

After

Width:  |  Height:  |  Size: 556 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 546 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

View file

@ -10,24 +10,274 @@ 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 {
e.textures = {_textures = {}}
setmetatable(e.textures, {
__newindex = function(tbl, key, value)
tbl._textures[idx] = value
p:set_properties {
textures = tbl._textures
}
end,
__index = e.textures._textures
})
e.hunger_bar = 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",
text = "rgt_pumpkin_alt.png",
number = 20,
item = 20,
text2 = "rgt_pumpkin_empty.png"
}
e.props = p:get_properties()
e.eye_height = 1.6
e.health_display = minetest.add_entity(p:get_pos(), "display")
e.health_display:set_attach(p, nil, vector.new(0, 17, 0))
e:update_hp(p:get_hp())
return e
end,
update_hp = function(m, hp)
if not (m.health_display and m.health_display:is_valid()) then
m.health_display = minetest.add_entity(m.object:get_pos(), "display")
m.health_display:set_attach(m.object, nil, vector.new(0, 17, 0))
end
local tx = "[combine:90x90"
for i = math.floor(hp /2), math.floor(m.props.hp_max /2) -1 do
tx = tx..":"..(i *9)..",0=rgt_heart_empty.png"
end
for i = 0, math.floor(hp /2) -1 do
tx = tx..":"..(i *9)..",0=rgt_heart.png"
end
if hp %2 ~= 0 then
tx = tx..":"..((math.floor(hp /2)) *9)..",0=rgt_heart.png\\^[fill\\:5x9\\:4,0\\:#000\\^[makealpha\\:#000"
end
m.health_display:set_properties {
visual = "sprite",
textures = {tx},
shaded = false
}
end,
tick = function(m, dtime)
local time = minetest.get_us_time()
local p = m.object
if not p or not p:is_player() then
return
end
local pitch = p:get_look_vertical()
local yaw = p:get_look_horizontal()
local dir = p:get_look_dir()
local pos = p:get_pos()
pos.y = pos.y +m.eye_height
-- Animation
if not m.in_third_person then
local c = p:get_player_control()
local moving = c.up or c.down or c.left or c.right
if moving then
m.moving = true
if c.aux1 and c.up then
if p:get_animation().y ~= 2 then p:set_animation({x=1, y=2}, 1.5, 0.2, true) end
p:set_physics_override{
speed = 1.5
}
else
if p:get_animation().y ~= 1 then p:set_animation({x=0, y=1}, 1.5, 0.2, true) end
p:set_physics_override{
speed = 1
}
end
else
m.moving = false
if p:get_animation().y ~= 0 then p:set_animation({x=0, y=0}) end
end
if not m.rot then m.rot = 0 end
if moving then
local fac = 0
if c.left then fac = 30 elseif c.right then fac = -30 end
m.rot = yaw +math.rad(fac)
elseif math.abs(yaw -m.rot) > math.rad(40) then
m.rot = m.rot +(yaw -(m.yaw or 0))
end
m.rot = m.rot %math.rad(360)
m.yaw = yaw
p:set_bone_override("Head", {
rotation = {vec = vector.new(math.min(math.max(pitch, math.rad(-60)), math.rad(60)),-(yaw -m.rot),0), interpolation = 0.1, absolute = true}
})
p:set_bone_override("root", {
rotation = {vec = vector.new(0,yaw -m.rot,0), interpolation = 0.1, absolute = true}
})
m.ctl = c
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()
local ppos = c:get_pos()
if not ppos then
m:enter_third_person_view(m.third_person_focus, me ~= false)
return
end
local dir = vector.new(0,0,1):rotate(vector.new(math.rad(-45),yaw,0))
-- if lv < 0 then
-- lv = 0
-- p:set_look_vertical(0)
-- end
local radius = m.third_person_camera_radius or 10
local t = (me and me:get_pos() or m.third_person_focus) +(-dir *radius)
-- local standing_on = minetest.get_node(pos:offset(0, -0.05, 0))
-- local can_jump = minetest.registered_nodes[standing_on.name].walkable
local dist = math.min(radius *2, t:distance(ppos) ^2)
local vel = t:direction(ppos) *dist
local tvel = vector.zero()
local was_moving = m.ctl.up or m.ctl.down or m.ctl.left or m.ctl.right or m.ctl.jump or m.ctl.sneak
local moving = ctl.up or ctl.down or ctl.left or ctl.right
-- if e.jumping == 0 and can_jump and ctl.jump then
-- e.jumping = 10
-- tvel = tvel +vector.new(0,5,0)
-- end
if ctl.jump then
tvel.y = 3
elseif ctl.sneak then
tvel.y = -3
end
if moving then
dir.y = 0
v_normalize(dir)
local rot = 0
if ctl.up then
if ctl.left then
rot = math.rad(45)
elseif ctl.right then
rot = math.rad(-45)
end
elseif ctl.down then
if ctl.left then
rot = math.rad(180 -45)
elseif ctl.right then
rot = math.rad(180 +45)
else
rot = math.rad(180)
end
elseif ctl.left then
rot = math.rad(90)
elseif ctl.right then
rot = math.rad(-90)
end
dir = dir:rotate(vector.new(0,rot,0))
if me then me:set_velocity(tvel +(dir *5)) end
vel = vel -(dir *5)
-- if not was_moving then
-- me:set_animation({x=0, y=1}, 1.5, 0.2, true)
-- end
-- me:set_bone_override("root", {
-- rotation = {
-- vec = -dir:dir_to_rotation(), interpolation = 0.07, absolute = true
-- }
-- })
elseif was_moving and me then
-- me:set_animation({x=0, y=0})
me:set_velocity(tvel)
end
-- e.jumping = math.max(0, e.jumping -1)
--vel.y = 0
c:set_velocity(-vel)
m.ctl = ctl
end
-- Health regen
-- TODO: Move to combat mod
if time -(m.last_time or 0) >= 10 *1000000 then
local hp = p:get_hp()
if hp < p:get_properties().hp_max then
p:set_hp(hp +1)
-- Make sure the health display is still loaded.
elseif not (m.health_display and m.health_display:is_valid()) then
m.health_display = minetest.add_entity(m.object:get_pos(), "display")
m.health_display:set_attach(m.object, nil, vector.new(0, 17, 0))
end
m.last_time = time
end
-- Custom on-hover effects
m.pointed_node = nil
local pointed_found = false
for pointed in minetest.raycast(pos, pos +(dir *7)) do -- TODO: Automatic range
if pointed and pointed.type == "object" then
local e = pointed.ref:get_luaentity()
if e then
local names_match = m.pointed_obj and (m.pointed_obj._name or m.pointed_obj.name) == (e._name or e.name)
if m.pointed_obj and not names_match then
if m.pointed_obj.on_unhover then
m.pointed_obj:on_unhover(m)
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
if e.on_hover then
m.hover_trigger_range = e:on_hover(m) or 8
end
pointed_found = true
m.pointed_obj = e
break
elseif m.pointed_obj and names_match and e.on_hover then
pointed_found = true
break
end
end
elseif pointed and pointed.type == "node" and not m.pointed_node then
m.pointed_node = pointed
end
end
if not pointed_found and m.pointed_obj then
if m.pointed_obj.on_unhover then
m.pointed_obj:on_unhover(m)
end
m.pointed_obj = nil
m.hover_trigger_range = nil
end
m.pos = pos
-- Run on_wield callbacks
local w = p:get_wielded_item()
local wname = w:get_name()
local def = minetest.registered_items[wname]
if m.prev_wielditem ~= wname then
if m.prev_wielditem then
local def = minetest.registered_items[m.prev_wielditem]
local onunselect = def and def.on_unwield
if onunselect then onunselect(m) end
end
m.prev_wielditem = wname
local onselect = def and def.on_wield
if onselect then onselect(m, w) end
end
local while_wielded = def and def.while_wielded
if while_wielded then while_wielded(m, w) end
end,
set_hotbar_size = function(m, slots)
local p = m.object
p:hud_set_hotbar_itemcount(slots)
@ -68,3 +318,28 @@ minetest.hud_replace_builtin("health", {
minetest.register_on_joinplayer(function(p)
ns.players[p:get_player_name()] = Player(p)
end)
minetest.register_on_leaveplayer(function(p)
ns.players[p:get_player_name()] = nil
end)
minetest.register_globalstep(function(time)
for _, x in pairs(rgt.players) do
x:tick(time)
end
end)
minetest.register_on_player_hpchange(function(p, hp_change)
rgt.players[p:get_player_name()]:update_hp(p:get_hp() +hp_change)
end)
minetest.register_chatcommand("hungerbar", {
func = function(name, args)
local m = rgt.players[name]
if args == "pumpkin_alt" then
m.object:hud_change(m.hunger_bar, "text", "rgt_"..args..".png")
else
m.object:hud_change(m.hunger_bar, "text", "rgt_pumpkin.png")
end
end
})

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1 @@
{"asset":{"version":"2.0","generator":"Blockbench 4.11.0 glTF exporter"},"scenes":[{"nodes":[3],"name":"blockbench_export"}],"scene":0,"nodes":[{"translation":[-7.341186189470692,-10.221666105894709,3.75],"name":"Right Arm","mesh":0},{"translation":[-7.341186189470692,-10.221666105894709,3.75],"name":"Right Arm Layer","mesh":1},{"rotation":[0.9829629131445342,0.12940952255126037,-0.017037086855465768,0.12940952255126018],"name":"RightArm","children":[0,1]},{"children":[2]}],"bufferViews":[{"buffer":0,"byteOffset":0,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":288,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":576,"byteLength":192,"target":34962,"byteStride":8},{"buffer":0,"byteOffset":768,"byteLength":72,"target":34963},{"buffer":0,"byteOffset":840,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":1128,"byteLength":288,"target":34962,"byteStride":12},{"buffer":0,"byteOffset":1416,"byteLength":192,"target":34962,"byteStride":8},{"buffer":0,"byteOffset":1608,"byteLength":72,"target":34963}],"bu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/AABAPwAAPD8AAEA/AAACAAEAAgADAAEABAAGAAUABgAHAAUACAAKAAkACgALAAkADAAOAA0ADgAPAA0AEAASABEAEgATABEAFAAWABUAFgAXABUA"}],"accessors":[{"bufferView":0,"componentType":5126,"count":24,"max":[4.375,15,0.9375],"min":[2.5,7.5,-0.9375],"type":"VEC3"},{"bufferView":1,"componentType":5126,"count":24,"max":[1,1,1],"min":[-1,-1,-1],"type":"VEC3"},{"bufferView":2,"componentType":5126,"count":24,"max":[0.827880859375,0.499755859375],"min":[0.640869140625,0.265869140625],"type":"VEC2"},{"bufferView":3,"componentType":5123,"count":36,"max":[23],"min":[0],"type":"SCALAR"},{"bufferView":4,"componentType":5126,"count":24,"max":[4.53125,15.15625,1.09375],"min":[2.34375,7.34375,-1.09375],"type":"VEC3"},{"bufferView":5,"componentType":5126,"count":24,"max":[1,1,1],"min":[-1,-1,-1],"type":"VEC3"},{"bufferView":6,"componentType":5126,"count":24,"max":[0.84375,0.75],"min":[0.640625,0.515625],"type":"VEC2"},{"bufferView":7,"componentType":5123,"count":36,"max":[23],"min":[0],"type":"SCALAR"}],"materials":[{"pbrMetallicRoughness":{"metallicFactor":0,"roughnessFactor":1,"baseColorTexture":{"index":0}},"alphaMode":"MASK","alphaCutoff":0.05,"doubleSided":true}],"textures":[{"sampler":0,"source":0,"name":"artifact_key.png"}],"samplers":[{"magFilter":9728,"minFilter":9728,"wrapS":33071,"wrapT":33071}],"images":[{"mimeType":"image/png"}],"meshes":[{"primitives":[{"mode":4,"attributes":{"POSITION":0,"NORMAL":1,"TEXCOORD_0":2},"indices":3,"material":0}]},{"primitives":[{"mode":4,"attributes":{"POSITION":4,"NORMAL":5,"TEXCOORD_0":6},"indices":7,"material":0}]}]}

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 117 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 214 B

After

Width:  |  Height:  |  Size: 203 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 205 B

View file

@ -1,10 +1,18 @@
rgt_realms = {
realms = {
void = {
name = "void",
label = "Void",
sky = {
type = "plain",
base_color = "#000"
}
},
surface = {
name = "surface",
label = "Surface",
max = vector.new(-31000, -5000, -31000),
min = vector.new(31000, 1000, 31000)
}
}
}

View file

@ -94,7 +94,7 @@ end
function ns.get_workspace(name)
local ws = db:get("workspace:"..name)
if ws then return mietest.deserialize(ws) end
if ws then return minetest.deserialize(ws) end
end
function ns.place_workspace(name, pos)
@ -127,12 +127,68 @@ function ns.clear_workspace(ws)
vm:write_to_map()
end
function ns.load_plot(ws, plot)
function ns.load_plot(ws, plot, actor)
if vector.distance(ws.size, rgt_towns.plots[plot].size) > 0.1 then
tell(actor, "Workspace size and plot size do not match!")
return
end
minetest.place_schematic(ws.pos, rgt_towns.plots[plot].schematic, nil, nil, true, {})
end
function ns.set_workspace_size(ws, x, y, z)
local vm_data = {}
function ns.init_plot(ws, lvl)
if lvl and lvl -1 > 0 and lvl < ws.size.y *15 then
lvl = lvl -1
local min = ws.pos
local max = vector.add(ws.pos, vector.multiply(ws.size, 15))
local vm = minetest.get_voxel_manip(min, max)
local area = VoxelArea(vm:get_emerged_area())
local c_grass = minetest.get_content_id("dirt_grass")
local c_path = minetest.get_content_id("path_grass")
local c_dirt = minetest.get_content_id("dirt")
vm:get_data(vm_data)
for x = min.x, max.x -1 do
for z = min.z, max.z -1 do
for y = 0, lvl do
vm_data[area:index(x, ws.pos.y +y, z)] = y == lvl and ((
x +1 == max.x or x == min.x or
z +1 == max.z or z == min.z or
x +2 == max.x and z +2 == max.z or
x +2 == max.x and z -1 == min.z or
x -1 == min.x and z +2 == max.z or
x -1 == min.x and z -1 == min.z
) and c_path or c_grass) or c_dirt
end
end
end
vm:set_data(vm_data)
vm:write_to_map()
end
end
function ns.set_workspace_size(name, x, y, z)
local ws = ns.get_workspace(name)
ws.size.x = x
ws.size.y = y
ws.size.z = z
db:set_string("workspace:"..name, minetest.serialize(ws))
for k, x in pairs(ns.workspaces[name]) do
if k ~= "marker" then
if x.remove then
elseif type(x) == "table" then
for _, y in pairs(x) do
minetest.delete_particlespawner(y)
end
else
minetest.delete_particlespawner(y)
end
end
end
ns.workspaces[name].outline = rgt_towns.add_cube(vector.offset(ws.pos, -0.5,-0.5,-0.5), vector.add(ws.pos, vector.multiply(ws.size, 15)):offset(-0.5,-0.5,-0.5))
end
function ns.export_workspace(ws, label)
@ -144,8 +200,10 @@ end
minetest.register_chatcommand("new_plot", {
func = function(name, args)
local ws = ns.place_workspace(name, minetest.get_player_by_name(name):get_pos())
if args == "clear" then
if args == "clear" then
ns.clear_workspace(ws)
else
ns.init_plot(ws, tonumber(args))
end
end
})
@ -159,7 +217,7 @@ minetest.register_chatcommand("load_plot", {
return
end
if args and args ~= "" then
ns.load_plot(ws, args)
ns.load_plot(ws, args, name)
end
end
})
@ -167,10 +225,14 @@ minetest.register_chatcommand("load_plot", {
minetest.register_chatcommand("set_plot_size", {
func = function(name, args)
if args and args ~= "" then
local x, y, z = args:match "(%d+)%s+(%d+)%s+(%d+)"
local x, y, z, regen, lvl = args:match "^(%d+)%s+(%d+)%s+(%d+)%s+(regenerate)%s+(%d+)"
if not x then return end
if not y then y = x end
if not z then z = x end
ns.set_workspace_size(ns.get_workspace(name), x, y, z)
ns.set_workspace_size(name, x, y, z)
if regen and lvl then
ns.init_plot(ns.get_workspace(name), tonumber(lvl))
end
tell(name, "Size set to "..x.."x"..y.."x"..z..".")
end
end

View file

@ -34,6 +34,7 @@ rgt_towns.register_plot{
label = "Empty Plot",
description = "Hello world",
schematic = minetest.get_modpath(minetest.get_current_modname()).."/schems/empty_plot.mts",
size = vector.new(1, 2, 1),
recipe = {
"", "", "",
"dirt_grass 1", "dirt_grass 1", "dirt_grass 1",
@ -48,6 +49,7 @@ rgt_towns.register_plot{
label = "House",
description = "Hello world",
schematic = minetest.get_modpath(minetest.get_current_modname()).."/schems/house.mts",
size = vector.new(1, 2, 1),
recipe = {
"oak_planks 1", "oak_planks 1", "oak_planks 1",
"oak_log 1", "glass 1", "oak_log 1",

View file

@ -30,6 +30,11 @@ rgt.register_node("dirt", {
groups = {dig_immediate = 3}
})
rgt.register_node("dirt_mossy", {
tiles = {{name = rep("rgt_dirt.png", 4).."^rgt_path_grass.png", scale = 4, align_style = "world"}, "rgt_dirt.png"},
groups = {dig_immediate = 3}
})
rgt.register_node("dirt_grass", {
tiles = {"rgt_grass_top.png", "rgt_dirt.png", "rgt_dirt.png^rgt_grass_side.png"},
-- tiles = {"[fill:16x16:0,0:#3e7e7b^[fill:14x14:1,1:#326764"},
@ -55,7 +60,14 @@ rgt.register_node("path_grass", {
rgt.register_node("oak_log", {
tiles = {"rgt_oak_log_top.png", "rgt_oak_log_side.png"},
tiles = {"rgt_oak_log_top.png", "rgt_oak_log_top.png", "rgt_oak_log_side.png"},
groups = {dig_immediate = 3}
})
rgt.register_node("oak_leaves", {
drawtype = "allfaces",
tiles = {"rgt_oak_leaves.png"},
use_texture_alpha = "clip",
groups = {dig_immediate = 3}
})
@ -132,8 +144,8 @@ rgt.register_node("water", {
})
rgt.register_node("water_flowing", {
tiles = {{name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = false}},
special_tiles = {{name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = false}, {name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = false}},
tiles = {{name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = true}},
special_tiles = {{name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = true}, {name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = true}},
groups = {dig_immediate = 3},
drawtype = "flowingliquid",
use_texture_alpha = "blend",
@ -150,8 +162,48 @@ rgt.register_node("water_flowing", {
liquid_range = 5,
})
rgt.register_node("river_water", {
tiles = {"[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33"},
groups = {dig_immediate = 3},
drawtype = "liquid",
use_texture_alpha = "blend",
paramtype = "light",
walkable = false,
climbable = true,
post_effect_color = "#2d5a7c55",
liquidtype = "source",
-- Minetest pro tip: Do not try to use aliases for these.
liquid_alternative_source = "red_glazed_terracotta:river_water",
liquid_alternative_flowing = "red_glazed_terracotta:river_water_flowing",
liquid_viscosity = 1,
liquid_range = 2,
liquid_renewable = false
})
rgt.register_node("river_water_flowing", {
tiles = {{name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = true}},
special_tiles = {{name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = true}, {name = "[fill:16x16:0,0:#2d5a7c77^[fill:14x14:1,1:#2d5a7c33", backface_culling = true}},
groups = {dig_immediate = 3},
drawtype = "flowingliquid",
use_texture_alpha = "blend",
paramtype = "light",
paramtype2 = "flowingliquid",
walkable = false,
climbable = true,
post_effect_color = "#2d5a7c55",
liquidtype = "flowing",
liquid_alternative_source = "red_glazed_terracotta:river_water",
liquid_alternative_flowing = "red_glazed_terracotta:river_water_flowing",
liquid_viscosity = 1,
liquid_range = 2,
liquid_renewable = false
})
minetest.register_alias("mapgen_stone", "red_glazed_terracotta:stone")
minetest.register_alias("mapgen_water_source", "red_glazed_terracotta:water")
minetest.register_alias("mapgen_river_water_source", "red_glazed_terracotta:river_water")
-- Remove
@ -160,6 +212,16 @@ minetest.register_alias("adrift:dirt", "red_glazed_terracotta:dirt")
minetest.register_alias("adrift:dirt_grass", "red_glazed_terracotta:dirt_grass")
minetest.register_alias("adrift:water", "red_glazed_terracotta:water")
--minetest.register_decoration {
-- deco_type = "schematic",
-- place_on = "dirt_grass",
-- 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 = "!",

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 386 B

After

Width:  |  Height:  |  Size: 440 B

Before After
Before After

Binary file not shown.

After

Width:  |  Height:  |  Size: 644 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 437 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 B

After

Width:  |  Height:  |  Size: 277 B

Before After
Before After