kirk24788 / KPS

Karnofsky Performance System
8 stars 11 forks source link

function usage in KPS #31

Closed htordeux closed 7 years ago

htordeux commented 7 years ago

I would like to update my priest rotation in KPS but there is something I don't understand with function usage Thanks question on forum

http://kazuhiro.nishi.co/keymoon/viewtopic.php?f=20&t=227

it seems that in Iam using a kps.multiTarget ( or any boolean kps.something) outside 'quotes' it keeps the same value either true or false e.g;

function kps.env.priest.testkps(val) if kps.multiTarget then return false end if val > 0 then return true end return false end

{spells.mindFlay, env.testkps(1) , "target"}, -- returns either always false or always true
{spells.mindFlay, 'testkps(1)' , "target"}, -- returns true /false
htordeux commented 7 years ago

Kirk24788 wrote: Next line: {spells.mindFlay, 'test' , "target"}, -- returns always true This looks up 'test' in the environment, but the function doesn't get called - you would have write 'test()' for this, instead you have a simplification of 'test ~= nil', which is always true if the function exists

thanks kirk,but... a test function without arg e.g. kps.env.priest.test() {spells.mindFlay, 'test()' }, -- return a lua error parser/lua:84 bad argument to unpack table expected got nil or un "fake" arg --{spells.mindFlay, 'test(1)' }, -- return true/false