Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Preserving scenario state across sessions?

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Air / Naval Operations >> Mods and Scenarios >> Lua Legion >> Preserving scenario state across sessions? Page: [1]
Login
Message << Older Topic   Newer Topic >>
Preserving scenario state across sessions? - 9/9/2018 1:22:48 PM   
SeaQueen


Posts: 760
Joined: 4/14/2007
From: Washington D.C.
Status: offline
I'm having difficulty with something which isn't LUA scripting per se, but is a problem raised by LUA scripting. It seems that when I save a game, the variables I set in LUA are not retained, so when I reload the scenario it re-initializes them. Has anyone found an adequate way of addressing the problem?

My scenarios tend to have a lot of counters, and perform a lot of math, in order to determine victory conditions, changes in plans, etc.
Post #: 1
RE: Preserving scenario state across sessions? - 9/9/2018 3:00:21 PM   
Whicker

 

Posts: 159
Joined: 6/20/2018
Status: online
I was wondering about that when I was looking at some of your actions.
I think you need to use keyvalues in order for them to persist across saves:

http://commandlua.github.io/#ScenEdit_SetKeyValue

there is a quirk there about them needing to be stings and not numbers - so I think you have to change them back and forth.

like:

ScenEdit_SetKeyValue("HalfHour", tostring(halfHour));
and then

local halfHour = ScenEdit_GetKeyValue("HalfHour");
halfHour = tonumber(halfHour);

(in reply to SeaQueen)
Post #: 2
RE: Preserving scenario state across sessions? - 9/9/2018 3:04:54 PM   
Whicker

 

Posts: 159
Joined: 6/20/2018
Status: online
not sure how that would work with your tables/objects. I kind of think they should just be individual variables but have never used a table with a keyvalue so not sure.

(in reply to Whicker)
Post #: 3
RE: Preserving scenario state across sessions? - 9/9/2018 3:15:46 PM   
SeaQueen


Posts: 760
Joined: 4/14/2007
From: Washington D.C.
Status: offline
Darn... that makes me sad. In some of my other creations which I haven't released, I used SetKeyValue()/GetKeyValue(). I was happy because I thought I'd discovered I could avoid using lots of tonumber() calls and it made my code a little more clear. I guess I was naive.

(in reply to Whicker)
Post #: 4
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Air / Naval Operations >> Mods and Scenarios >> Lua Legion >> Preserving scenario state across sessions? Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.102