Page 1 of 1

Lua- How to remember stuff

Posted: Tue Oct 21, 2014 8:03 am
by BadPractice
HI,
I am trying to make my own mod/ruleset to celebrate diseases! Diseases are awsome!

However i ran in some issues i dont seem to get my head around. How do i save a variable in my lua script so i can acess it at my next callback. A little example:

Code: Select all

function units_getting_sick_callback(turn, year)
    if var = 0 then
      var = 1
    end

   if var = 1 then
      notify.all( " callback is called the 2nd time")
    end
end

Re: Lua- How to remember stuff

Posted: Tue Oct 21, 2014 10:09 am
by sveinung
Define the variable outside the function.