Fixed dysfunctional condition change bug

Typo preventing condition changes from working was fixed, along with tweaks to the original calculation.
Now the penalty for negative relative condition is less drastic and always degrades the plant by 1.
master
Avicennia_g 2020-10-25 02:48:05 -07:00 committed by GitHub
parent cc2233c423
commit ba3836ec71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View File

@ -42,7 +42,7 @@ rhynia.f.calc_condition = function(ci,gl,p2,r,genus) -- returns condition value
local p2 = p2 > 0 and p2 or 1
local cs = lims[p2]
local v = ci-(cs*(gl-2 >-1 and gl-2 or 0)) -- where ci = condition index, gl = growth level, cs = condition standard (the value at the level for that condition as calculated)
local v = (ci)-(cs*(gl-2 >0 and gl or 0)) -- where ci = condition index, gl = growth level, cs = condition standard (the value at the level for that condition as calculated)
local function incr_chk(a) -- Logical comparison of current ci with standard condition values, checks value incrementally and stops when ci isnt higher than the next number
-- WIP: undo unnecessary function definition ~~
local ind = 0
@ -50,7 +50,7 @@ rhynia.f.calc_condition = function(ci,gl,p2,r,genus) -- returns condition value
for s = 1, 4 do
local ind_s = ind
ind = igi(a,lims[s])
if(ind_s == ind)then return ind end
if(ind_s == ind)then return ind>=p2 and ind or p2-1 end
end
ind = ind > 4 and 4 or ind
return ind
@ -71,3 +71,6 @@ rhynia.f.average_light_spot = function(pos) -- WIP: undo unnecessary function de
return area and area[1] and lux_iterate()
end
rhynia.f.reset_condition = function(pos)
return minetest.get_meta(pos):set_int("rhynia_ci",0)
end

View File

@ -65,7 +65,7 @@ rhynia.f.grow = function(pos, genus, stage) -- Rebuilds plant using next genus s
local function build(pos)
local m = minetest.get_meta(pos)
local gl,ci,p2 = m:get_int("rhynnia_gl"),m:get_int("rhynia_ci"),data.nd.param2
local gl,ci,p2 = m:get_int("rhynia_gl"),m:get_int("rhynia_ci"),data.nd.param2
local p2 = rhynia.f.calc_condition(ci,gl,p2,_,genus)
local p, s = pos and {x = pos.x, y = pos.y, z = pos.z},rhynia.genera[data.genus].structure[v]
@ -73,7 +73,7 @@ rhynia.f.grow = function(pos, genus, stage) -- Rebuilds plant using next genus s
if(p and s[n] and airchk(p)) then
local m = minetest.get_meta(p)
rhynia.u.swn(p,s[n],p2)
m:set_int("rhynia_gi",(0))
m:set_int("rhynia_gi",0)
local newgl = data.gl + 1 < data.stmax and data.gl + 1 or data.stmax
m:set_int("rhynia_gl",newgl)
end