mirror of
https://github.com/FaceDeer/dfcaverns.git
synced 2024-11-14 14:40:29 +01:00
update spindlestem growth code, remove deprecated functions
This commit is contained in:
parent
96e6ecefe7
commit
84efae02c4
|
@ -136,7 +136,7 @@ local place_seed = function(itemstack, placer, pointed_thing, plantname)
|
||||||
-- add the node and remove 1 item from the itemstack
|
-- add the node and remove 1 item from the itemstack
|
||||||
minetest.add_node(pt.above, {name = plantname, param2 = 1})
|
minetest.add_node(pt.above, {name = plantname, param2 = 1})
|
||||||
df_farming.plant_timer(pt.above, plantname)
|
df_farming.plant_timer(pt.above, plantname)
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.settings:get_bool("creative_mode", false) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
|
|
|
@ -50,7 +50,7 @@ local plump_helmet_on_place = function(itemstack, placer, pointed_thing, plantn
|
||||||
-- add the node and remove 1 item from the itemstack
|
-- add the node and remove 1 item from the itemstack
|
||||||
minetest.add_node(pt.above, {name = plantname, param2 = math.random(0,3)})
|
minetest.add_node(pt.above, {name = plantname, param2 = math.random(0,3)})
|
||||||
df_farming.plant_timer(pt.above, plantname)
|
df_farming.plant_timer(pt.above, plantname)
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.settings:get_bool("creative_mode", false) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
|
|
|
@ -59,7 +59,7 @@ df_mapitems.place_against_surface = function(itemstack, placer, pointed_thing)
|
||||||
end
|
end
|
||||||
-- add the node and remove 1 item from the itemstack
|
-- add the node and remove 1 item from the itemstack
|
||||||
minetest.add_node(above_pos, {name = itemstack:get_name(), param2 = param2})
|
minetest.add_node(above_pos, {name = itemstack:get_name(), param2 = param2})
|
||||||
if not minetest.setting_getbool("creative_mode") and not minetest.check_player_privs(placer, "creative") then
|
if not minetest.settings:get_bool("creative_mode", false) and not minetest.check_player_privs(placer, "creative") then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
|
|
|
@ -46,7 +46,7 @@ local stem_on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
-- add the node and remove 1 item from the itemstack
|
-- add the node and remove 1 item from the itemstack
|
||||||
minetest.add_node(pt.above, {name = itemstack:get_name(), param2 = new_param2})
|
minetest.add_node(pt.above, {name = itemstack:get_name(), param2 = new_param2})
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.settings:get_bool("creative_mode", false) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
|
@ -149,23 +149,34 @@ local register_spindlestem_type = function(item_suffix, colour_name, colour_code
|
||||||
|
|
||||||
on_place = stem_on_place,
|
on_place = stem_on_place,
|
||||||
on_timer = function(pos, elapsed)
|
on_timer = function(pos, elapsed)
|
||||||
local above = vector.add(pos, {x=0,y=1,z=0})
|
|
||||||
local node_above = minetest.get_node(above)
|
|
||||||
local above_def = minetest.registered_nodes[node_above.name]
|
|
||||||
if not above_def or not above_def.buildable_to then
|
|
||||||
-- can't grow any more, exit
|
|
||||||
return
|
|
||||||
end
|
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
local height = meta:get_int("spindlestem_to_grow")
|
local height = meta:get_int("spindlestem_to_grow")
|
||||||
|
local delay = meta:get_int("spindlestem_delay")
|
||||||
|
if delay == 0 then
|
||||||
|
delay = growth_delay() -- compatibility code to ensure no crash for previous version
|
||||||
|
end
|
||||||
local node = minetest.get_node(pos)
|
local node = minetest.get_node(pos)
|
||||||
minetest.set_node(pos, {name="df_trees:spindlestem_stem", param2 = node.param2})
|
|
||||||
minetest.set_node(above, {name=cap_item, param2 = node.param2})
|
while height > 0 and elapsed >= delay do
|
||||||
height = height - 1
|
elapsed = elapsed - delay
|
||||||
|
local this_pos = pos
|
||||||
|
pos = vector.add(this_pos, {x=0,y=1,z=0})
|
||||||
|
local node_above = minetest.get_node(pos)
|
||||||
|
local above_def = minetest.registered_nodes[node_above.name]
|
||||||
|
if not above_def or not above_def.buildable_to then
|
||||||
|
-- can't grow any more, exit
|
||||||
|
return
|
||||||
|
end
|
||||||
|
minetest.set_node(this_pos, {name="df_trees:spindlestem_stem", param2 = node.param2})
|
||||||
|
minetest.set_node(pos, {name=cap_item, param2 = node.param2})
|
||||||
|
height = height - 1
|
||||||
|
end
|
||||||
|
|
||||||
if height > 0 then
|
if height > 0 then
|
||||||
meta = minetest.get_meta(above)
|
meta = minetest.get_meta(above)
|
||||||
meta:set_int("spindlestem_to_grow", height)
|
meta:set_int("spindlestem_to_grow", height)
|
||||||
minetest.get_node_timer(above):start(growth_delay())
|
meta:set_int("spindlestem_delay", delay)
|
||||||
|
minetest.get_node_timer(above):start(delay-elapsed)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -255,7 +266,7 @@ minetest.register_node("df_trees:spindlestem_seedling", {
|
||||||
minetest.get_node_timer(pos):stop()
|
minetest.get_node_timer(pos):stop()
|
||||||
end,
|
end,
|
||||||
|
|
||||||
on_timer = function(pos)
|
on_timer = function(pos, elapsed)
|
||||||
if df_farming and df_farming.kill_if_sunlit(pos) then
|
if df_farming and df_farming.kill_if_sunlit(pos) then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -270,8 +281,10 @@ minetest.register_node("df_trees:spindlestem_seedling", {
|
||||||
local height = math.random(1,3)
|
local height = math.random(1,3)
|
||||||
if count > 10 then height = height + 2 end -- if there are a lot of nearby spindlestems, grow taller
|
if count > 10 then height = height + 2 end -- if there are a lot of nearby spindlestems, grow taller
|
||||||
if height > 0 then
|
if height > 0 then
|
||||||
|
local delay = growth_delay()
|
||||||
meta:set_int("spindlestem_to_grow", height)
|
meta:set_int("spindlestem_to_grow", height)
|
||||||
minetest.get_node_timer(pos):start(growth_delay())
|
meta:set_int("spindlestem_delay", delay)
|
||||||
|
minetest.get_node_timer(pos):start(delay)
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
@ -320,7 +333,7 @@ local c_cyan = minetest.get_content_id("df_trees:spindlestem_cap_cyan")
|
||||||
local c_golden = minetest.get_content_id("df_trees:spindlestem_cap_golden")
|
local c_golden = minetest.get_content_id("df_trees:spindlestem_cap_golden")
|
||||||
|
|
||||||
get_spindlestem_cap_type = function(pos)
|
get_spindlestem_cap_type = function(pos)
|
||||||
if pos.y > -100 or minetest.find_node_near(pos, 15, "group:tower_cap") then
|
if minetest.find_node_near(pos, 15, "group:tower_cap") then
|
||||||
return c_white
|
return c_white
|
||||||
end
|
end
|
||||||
if minetest.find_node_near(pos, 15, "group:goblin_cap") then
|
if minetest.find_node_near(pos, 15, "group:goblin_cap") then
|
||||||
|
@ -336,7 +349,6 @@ get_spindlestem_cap_type = function(pos)
|
||||||
if copper then table.insert(possibilities, c_green) end
|
if copper then table.insert(possibilities, c_green) end
|
||||||
if iron then table.insert(possibilities, c_red) end
|
if iron then table.insert(possibilities, c_red) end
|
||||||
if iron and copper then table.insert(possibilities, c_cyan) end
|
if iron and copper then table.insert(possibilities, c_cyan) end
|
||||||
|
|
||||||
if #possibilities == 0 then
|
if #possibilities == 0 then
|
||||||
return c_white
|
return c_white
|
||||||
else
|
else
|
||||||
|
|
|
@ -43,7 +43,7 @@ local stal_on_place = function(itemstack, placer, pointed_thing)
|
||||||
|
|
||||||
-- add the node and remove 1 item from the itemstack
|
-- add the node and remove 1 item from the itemstack
|
||||||
minetest.add_node(pt.above, {name = itemstack:get_name(), param2 = new_param2})
|
minetest.add_node(pt.above, {name = itemstack:get_name(), param2 = new_param2})
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
if not minetest.settings:get_bool("creative_mode", false) then
|
||||||
itemstack:take_item()
|
itemstack:take_item()
|
||||||
end
|
end
|
||||||
return itemstack
|
return itemstack
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 6940ae15859f671afbeb2231f90ce58914bb774f
|
Subproject commit 1abfc23dd369899c1b6c4888799bcdc4525558a4
|
Loading…
Reference in New Issue
Block a user