Prevent players getting free mk1 stasis chambers.
This commit is contained in:
parent
d7e079ae20
commit
a372a5a1b8
|
@ -134,7 +134,11 @@ stasis.register_chamber = function(name, def)
|
||||||
end
|
end
|
||||||
|
|
||||||
active_def.after_dig_node = function(pos, oldnode, meta, player)
|
active_def.after_dig_node = function(pos, oldnode, meta, player)
|
||||||
player:get_inventory():add_item('main', stasis.begin_transit(meta.fields.victim, name))
|
player:get_inventory():add_item('main', stasis.begin_transit(
|
||||||
|
meta.fields.victim,
|
||||||
|
replace_with,
|
||||||
|
name .. '_active'
|
||||||
|
))
|
||||||
end
|
end
|
||||||
active_def.on_construct = nil
|
active_def.on_construct = nil
|
||||||
active_def.on_dig = nil
|
active_def.on_dig = nil
|
||||||
|
|
14
core.lua
14
core.lua
|
@ -110,7 +110,7 @@ local formspec_transit_end = 'size[4,2.5]'
|
||||||
.. 'button_exit[0,0.5;4,1;leave_chamber;Leave stasis chamber]'
|
.. 'button_exit[0,0.5;4,1;leave_chamber;Leave stasis chamber]'
|
||||||
.. 'button_exit[0,1.5;4,1;quit;Remain in stasis]'
|
.. 'button_exit[0,1.5;4,1;quit;Remain in stasis]'
|
||||||
|
|
||||||
stasis.begin_transit = function(victim, chamber)
|
stasis.begin_transit = function(victim, chamber, active_chamber)
|
||||||
if victim and type(victim) ~= 'string' then
|
if victim and type(victim) ~= 'string' then
|
||||||
victim = victim:get_player_name()
|
victim = victim:get_player_name()
|
||||||
end
|
end
|
||||||
|
@ -119,6 +119,10 @@ stasis.begin_transit = function(victim, chamber)
|
||||||
return {name = chamber or 'stasis:chamber'}
|
return {name = chamber or 'stasis:chamber'}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not active_chamber then
|
||||||
|
active_chamber = chamber .. '_active'
|
||||||
|
end
|
||||||
|
|
||||||
minetest.show_formspec(victim, 'stasis:in_transit', formspec_transit_start)
|
minetest.show_formspec(victim, 'stasis:in_transit', formspec_transit_start)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -126,6 +130,7 @@ stasis.begin_transit = function(victim, chamber)
|
||||||
metadata = minetest.serialize({
|
metadata = minetest.serialize({
|
||||||
player_in_transit = victim,
|
player_in_transit = victim,
|
||||||
stasis_chamber = chamber,
|
stasis_chamber = chamber,
|
||||||
|
active_chamber = active_chamber,
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -157,8 +162,9 @@ minetest.register_node('stasis:player', {
|
||||||
|
|
||||||
after_place_node = function(pos, placer, itemstack)
|
after_place_node = function(pos, placer, itemstack)
|
||||||
local metadata = minetest.deserialize(itemstack:get_metadata()) or {}
|
local metadata = minetest.deserialize(itemstack:get_metadata()) or {}
|
||||||
local victim = metadata.player_in_transit or 'singleplayer'
|
local victim = metadata.player_in_transit or 'singleplayer'
|
||||||
local chamber = metadata.stasis_chamber or 'stasis:chamber'
|
local chamber = metadata.stasis_chamber or 'stasis:chamber'
|
||||||
|
local active_chamber = metadata.active_chamber or chamber .. '_active'
|
||||||
local p2 = minetest.get_node(pos).param2
|
local p2 = minetest.get_node(pos).param2
|
||||||
minetest.set_node(pos, {name = chamber, param2 = p2})
|
minetest.set_node(pos, {name = chamber, param2 = p2})
|
||||||
if minetest.registered_nodes[chamber].on_construct then
|
if minetest.registered_nodes[chamber].on_construct then
|
||||||
|
@ -167,7 +173,7 @@ minetest.register_node('stasis:player', {
|
||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
meta:set_string('victim', victim)
|
meta:set_string('victim', victim)
|
||||||
if stasis.end_transit(victim, pos) then
|
if stasis.end_transit(victim, pos) then
|
||||||
minetest.swap_node(pos, {name = chamber .. '_active', param2 = p2})
|
minetest.swap_node(pos, {name = active_chamber, param2 = p2})
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue