Allow command functions in /teleport and fix lava-water collisions

This commit is contained in:
IamPyu 2024-12-11 16:29:24 -06:00
parent 95b119bc65
commit 91a91e3e43
3 changed files with 25 additions and 16 deletions

View File

@ -44,6 +44,7 @@ Other Game Changes:
- Added Peach color
- Replaced single Haybales blocks spawning in Plains biome with Haybale and Pumpkin pastures
- Re-added Barriers
- Fixed lava-water collisions
Code Changes:

View File

@ -64,7 +64,8 @@ core.register_chatcommand("teleport", {
description = "Teleport <player> to <x> <y> <z>",
privs = {teleport = true},
func = function(name, param)
local found, _, player, x, y, z = param:find("^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+([^%s]+)$")
local found, _, player, x, y, z = PyuTest.parse_command_functions(name, param)
:find("^([^%s]+)%s+([^%s]+)%s+([^%s]+)%s+([^%s]+)$")
if found == nil then
core.chat_send_player(name, "Invalid usage: " .. param)

View File

@ -54,33 +54,40 @@ core.register_abm({
core.register_abm({
nodenames = { "group:lava" },
interval = 0.25,
interval = 1,
chance = 1,
action = function(pos)
local function is_water(p)
local name = core.get_node(p).name
if core.get_item_group(name, "water") ~= 0 then
return true
end
return false
return core.get_item_group(name, "water") ~= 0
end
local function replace(name, p)
core.set_node(p or pos, { name = name })
end
PyuTest.dorange(pos, 1, function(p)
if is_water(p) then
if p.y > pos.y then
replace("pyutest_blocks:obsidian_block")
elseif p.y < pos.y then
replace("pyutest_blocks:stone_block", p)
else
replace("pyutest_blocks:stone_block")
local p1 = vector.new(pos.x, pos.y + 1, pos.z)
local p2 = vector.new(pos.x, pos.y - 1, pos.z)
if is_water(p1) then
replace("pyutest_blocks:obsidian_block")
return
end
if is_water(p2) then
replace("pyutest_blocks:stone_block", p2)
return
end
for dx = -1, 1 do
for dz = -1, 1 do
local p3 = vector.new(pos.x + dx, pos.y, pos.z + dz)
if is_water(p3) then
replace("pyutest_blocks:cobblestone_block")
return
end
end
end)
end
end
})