mirror of
https://github.com/joe7575/techpack.git
synced 2024-11-22 15:23:43 +01:00
Merge pull request #27 from obl3pplifp/master
Fixes for Blocky Survival
This commit is contained in:
commit
84e574156e
@ -305,7 +305,7 @@ function NodeStates:keep_running(pos, meta, val, num_items)
|
|||||||
if self.aging_level1 then
|
if self.aging_level1 then
|
||||||
local cnt = meta:get_int("tubelib_aging") + num_items
|
local cnt = meta:get_int("tubelib_aging") + num_items
|
||||||
meta:set_int("tubelib_aging", cnt)
|
meta:set_int("tubelib_aging", cnt)
|
||||||
if (cnt > (self.aging_level1) and math.random(self.aging_level2/num_items) == 1)
|
if (cnt > (self.aging_level1) and math.random(math.max(1, math.floor(self.aging_level2/num_items))) == 1)
|
||||||
or cnt >= 999999 then
|
or cnt >= 999999 then
|
||||||
self:defect(pos, meta)
|
self:defect(pos, meta)
|
||||||
end
|
end
|
||||||
@ -431,7 +431,7 @@ end
|
|||||||
function NodeStates:after_dig_node(pos, oldnode, oldmetadata, digger)
|
function NodeStates:after_dig_node(pos, oldnode, oldmetadata, digger)
|
||||||
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
|
local inv = minetest.get_inventory({type="player", name=digger:get_player_name()})
|
||||||
local cnt = oldmetadata.fields.tubelib_aging and tonumber(oldmetadata.fields.tubelib_aging) or 0
|
local cnt = oldmetadata.fields.tubelib_aging and tonumber(oldmetadata.fields.tubelib_aging) or 0
|
||||||
local is_defect = cnt > self.aging_level1 and math.random(self.aging_level2 / cnt) == 1
|
local is_defect = cnt > self.aging_level1 and math.random(math.max(1, math.floor(self.aging_level2 / cnt))) == 1
|
||||||
if self.node_name_defect and is_defect then
|
if self.node_name_defect and is_defect then
|
||||||
inv:add_item("main", ItemStack(self.node_name_defect))
|
inv:add_item("main", ItemStack(self.node_name_defect))
|
||||||
else
|
else
|
||||||
|
@ -36,8 +36,10 @@ local Level2Idx = {[2]=1, [1]=2, [0]=3, [-1]=4, [-2]=5, [-3]=6,
|
|||||||
[-5]=7, [-10]=8, [-15]=9, [-20]=10}
|
[-5]=7, [-10]=8, [-15]=9, [-20]=10}
|
||||||
|
|
||||||
local function formspec(self, pos, meta)
|
local function formspec(self, pos, meta)
|
||||||
local depth = meta:get_int("max_levels") or 1
|
local depth = meta:get_int("max_levels")
|
||||||
local start_level = meta:get_int("start_level") or 1
|
if not Depth2Idx[depth] then depth = 1 end
|
||||||
|
local start_level = meta:get_int("start_level")
|
||||||
|
if not Level2Idx[start_level] then start_level = 0 end
|
||||||
local endless = meta:get_int("endless") or 0
|
local endless = meta:get_int("endless") or 0
|
||||||
local fuel = meta:get_int("fuel") or 0
|
local fuel = meta:get_int("fuel") or 0
|
||||||
-- some recalculations
|
-- some recalculations
|
||||||
|
Loading…
Reference in New Issue
Block a user