seems using this type of code
Code: Select all
something = something or somethingelse
doesn't work if done as local
Been testing some code for party heals and have this
Code: Select all
_firsttimes = _firsttimes or false
if _firsttimes == false then
cprintf(cli.yellow,"Party member "..i.." has the name of ")
cprintf(cli.red, GetPartyMemberName(i).."\n")
_firsttimes = true
end
If I do
Code: Select all
local _firsttimes = _firsttimes or false
it doesn't work and always says it is false
--=== Update ===--
Actually minor correction, it does work but you can't change the value with
_firsttimes = true, so if it is going to be that value without alteration then it works just fine. If you want to be able to change it later then you will probably have to make it not local.
In the end I gave up trying to make it a local, in my case anyway.
Code: Select all
if _firsttimes == nil then -- post party names when bot started
if GetPartyMemberName(i) ~= nil then
cprintf(cli.yellow,"Party member "..i.." has the name of ")
cprintf(cli.red, GetPartyMemberName(i).."\n")
_firsttimes = true
end
end
So I have a global which i only use just once and never use anywhere else, can't think of how else to do it. This code is within a loop and I only want the prints done the first time code us done.