Various different changes

This commit is contained in:
IamPyu 2024-10-27 16:57:04 -06:00
parent ecafa581bb
commit f881682777
8 changed files with 66 additions and 23 deletions

View File

@ -271,3 +271,10 @@ PyuTest.give_item_or_drop = function(stack, inventory, listname, pos)
minetest.add_item(pos, leftover)
end
end
PyuTest.get_biome_def = function(pos)
local data = minetest.get_biome_data(pos)
if not data then return end
return minetest.registered_biomes[minetest.get_biome_name(data.biome)]
end

View File

@ -6,7 +6,7 @@ PATH_FIND_ALGORITHM = "Dijkstra"
PyuTest.ENTITY_BLOOD_AMOUNT = 6
PyuTest.HUMAN_LIKE_CBOX = {-0.25, -1, -0.25, 0.25, 1, 0.25}
PyuTest.get_nearest_entity = function (entity, pos, range, only_player)
PyuTest.get_nearest_entity = function (entity, pos, range, only_player, dont_ignore_allies)
local closet_distance = math.huge
local nearest
@ -28,7 +28,15 @@ PyuTest.get_nearest_entity = function (entity, pos, range, only_player)
-- Ignore items
if e then
if e.name ~= "__builtin:item" then
set_nearest_and_distance(obj, dist)
if not dont_ignore_allies then
local self = entity:get_luaentity()
if self then
if self.name ~= e.name then
set_nearest_and_distance(obj, dist)
end
end
end
end
else
set_nearest_and_distance(obj, dist)
@ -94,7 +102,7 @@ local class = {}
function class:do_physics()
local obj = self.object
local data = self.data
local state = self.state
local cfg = self.options
local moveresult = self.moveresult
local pos = obj:get_pos()
@ -109,31 +117,31 @@ end
function class:path_find_nearest_entity(follow_only_player)
local obj = self.object
local data = self.data
local state = self.state
local cfg = self.options
local pos = obj:get_pos()
if data.target.path == nil then
data.target.object = PyuTest.get_nearest_entity(obj, pos, cfg.sight_range, follow_only_player)
if state.target.path == nil then
state.target.object = PyuTest.get_nearest_entity(obj, pos, cfg.sight_range, follow_only_player)
if data.target.object == nil then
if state.target.object == nil then
return
end
data.target.position = data.target.object:get_pos()
data.target.path = minetest.find_path(pos, data.target.position, cfg.view_range, cfg.max_jump, cfg.max_drop, PATH_FIND_ALGORITHM)
data.target.pathindex = 1
state.target.position = state.target.object:get_pos()
state.target.path = minetest.find_path(pos, state.target.position, cfg.view_range, cfg.max_jump, cfg.max_drop, PATH_FIND_ALGORITHM)
state.target.pathindex = 1
else
if data.target.pathindex == #data.target.path then
data.target.path = nil
data.target.object = nil
data.target.position = nil
data.target.pathindex = nil
if state.target.pathindex == #state.target.path then
state.target.path = nil
state.target.object = nil
state.target.position = nil
state.target.pathindex = nil
else
local p = data.target.path[data.target.pathindex]
local p = state.target.path[state.target.pathindex]
-- obj:set_velocity(p * dtime)
obj:move_to(p, true)
data.target.pathindex = data.target.pathindex + 1
state.target.pathindex = state.target.pathindex + 1
end
end
end
@ -182,7 +190,7 @@ PyuTest.make_mob = function (name, properties, options)
infotext = "",
}),
options = cfg,
data = {
state = {
target = {
object = nil,
position = nil,

View File

@ -152,7 +152,7 @@ PyuTest.make_building_blocks("pyutest_blocks:ice", "Ice", { "pyutest-ice.png" },
acid_vulnerable = 1,
slippery = 4,
cracky = PyuTest.BLOCK_FAST,
thawable = 1
thawable = 1,
})
PyuTest.make_building_blocks("pyutest_blocks:molten_rock", "Molten Rock", { "pyutest-molten-rock.png" }, nil, {

View File

@ -196,6 +196,14 @@ PyuTest.make_node("pyutest_blocks:bedrock", "Bedrock", {
is_ground_content = false
})
PyuTest.make_node("pyutest_blocks:weak_ice", "Weak Ice", {
cracky = PyuTest.BLOCK_FAST
}, {"pyutest-ice.png"}, {
on_walk_over = function(pos)
minetest.set_node(pos, {name = "pyutest_blocks:water_source"})
end
})
minetest.register_abm({
label = "Sponge Loop",
nodenames = { "pyutest_blocks:sponge" },

View File

@ -1,19 +1,39 @@
minetest.register_abm({
label = "Water freezing",
label = "Water freezing/evaporating",
nodenames = {"group:water"},
interval = 3,
chance = 2.5,
catch_up = true,
action = function (pos)
local heat = minetest.get_heat(pos) or 50
local def = PyuTest.get_biome_def(pos)
if not def then return end
local heat = def.heat_point or 50
local found = minetest.find_node_near(pos, 2, {"group:emits_heat"}) ~= nil
if heat < 12 and not found then
if heat <= 12 and not found then
minetest.set_node(pos, {name = "pyutest_blocks:ice_block"})
end
end
})
minetest.register_abm({
label = "Water evaporating",
nodenames = {"group:water"},
interval = 0.1,
chance = 1,
action = function (pos)
local def = PyuTest.get_biome_def(pos)
if not def then return end
local heat = def.heat_point or 50
if heat >= 100 then
minetest.remove_node(pos)
end
end
})
minetest.register_abm({
label = "Ice thawing",
nodenames = {"group:thawable"},

View File

@ -158,7 +158,7 @@ if PyuTest.is_flat() then
heat_point = 50,
humidity_point = 50,
}, true)
})
return
end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 B

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 188 B