Post subject: Easy question about LUA scripting
Joined: 11/1/2013
Posts: 13
Trying to make my script load a save state when it starts. Looking at the notes here: https://code.google.com/p/vba-rerecording/wiki/LuaScriptingFunctions I tried this: local asdf savestate.create(1) savestate.load(asdf) Which gave me this: ..\VisualBoyAdvance\lua\mmbn 3 blue flashman.lua:40: object not a savestate object Very new to TAS and LUA. What obvious mistake am I making? Thanks, Tterraj42
Games!
Editor, Skilled player (1534)
Joined: 7/9/2010
Posts: 1319
Maybe you should put savestate.save(asdf) into your script.
Favorite animal: STOCK Gt(ROSA)26Sortm1.1(rtTA,EGFP)Nagy Grm7Tg(SMN2)89Ahmb Smn1tm1Msd Tg(SMN2*delta7)4299Ahmb Tg(tetO-SMN2,-luc)#aAhmb/J YouTube Twitch
Joined: 11/1/2013
Posts: 13
TASeditor wrote:
Maybe you should put savestate.save(asdf) into your script.
But the save state already exists, and I want the script to load it.
Games!
Site Admin, Skilled player (1250)
Joined: 4/17/2010
Posts: 11468
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
I think what exists is an empty object. You assign the value to it by saving something.
Warning: When making decisions, I try to collect as much data as possible before actually deciding. I try to abstract away and see the principles behind real world events and people's opinions. I try to generalize them and turn into something clear and reusable. I hate depending on unpredictable and having to make lottery guesses. Any problem can be solved by systems thinking and acting.
Emulator Coder, Site Developer, Former player
Joined: 11/6/2004
Posts: 833
I think there's an = sign missing It's being interpreted as
local asdf;
savestate.create(1);
savestate.load(asdf)
since semicolons are optional in lua
Player (80)
Joined: 8/5/2007
Posts: 865
The following has never failed me:
Language: lua

state1=savestate.create() savestate.save(state1) --[[ a bunch of code emu.frameadvance() some more code ]]-- savestate.load(state1)
It has some differences with your code. Try copying and pasting it and working from that framework. Report back if you figure out what the problem was. (My money is on the equals sign, as DeHackEd mentioned, provided that you copied your code accurately.)
Joined: 1/26/2009
Posts: 558
Location: Canada - Québec
Usualy this code should work with emulator based on fceux lua engine, but for some reason it doesn't work with vba-rr.
mySavestate = savestate.create(1); 
savestate.load(mySavestate);
Editor, Expert player (2071)
Joined: 6/15/2005
Posts: 3282
VBA's Lua savestating is messed up, unfortunately. Don't use it. - savestate.create() only works in VBA when there is nothing in the brackets (e.g. savestate.create(1) doesn't work). - Savestates created by Lua in VBA may cause desyncs.