Post subject: Help with lua script?
Real96
He/Him
Joined: 3/19/2016
Posts: 15
I'm making a lua script for DeSmuMe. I want to use this command to save a value on save state: savestate.registersave(function() return frame end). But the emulator gives me this error: :50: attempt to call field 'registersave' (a nil value). Why? How can i solve this error?
Masterjun
He/Him
Site Developer, Skilled player (1987)
Joined: 10/12/2010
Posts: 1185
Location: Germany
There is no function in DeSmuMe that is being called when you save a state. The only thing you can do is use lua itself to save a state (with the savestate.save() and savestate.load() functions).
Warning: Might glitch to credits I will finish this ACE soon as possible (or will I?)
Post subject: Re: Help with lua script?
Real96
He/Him
Joined: 3/19/2016
Posts: 15
Masterjun wrote:
There is no function in DeSmuMe that is being called when you save a state. The only thing you can do is use lua itself to save a state (with the savestate.save() and savestate.load() functions).
Ah ok...so there is no solution for this t.t thanks!
Site Admin, Skilled player (1251)
Joined: 4/17/2010
Posts: 11475
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Attach to keyboard key that you use to save a state?
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.
Real96
He/Him
Joined: 3/19/2016
Posts: 15
feos wrote:
Attach to keyboard key that you use to save a state?
I need to make save state and reload back all the value...but the problem is that i can't relaod the correct "frame". I can pass you the code if you want...so you can understand...
Site Admin, Skilled player (1251)
Joined: 4/17/2010
Posts: 11475
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Ok.
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.
Real96
He/Him
Joined: 3/19/2016
Posts: 15
Solved. Thanks for the answer guys!
Masterjun
He/Him
Site Developer, Skilled player (1987)
Joined: 10/12/2010
Posts: 1185
Location: Germany
np
Warning: Might glitch to credits I will finish this ACE soon as possible (or will I?)
Site Admin, Skilled player (1251)
Joined: 4/17/2010
Posts: 11475
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
How? Here's my example but it doesn't fire consistently for some odd reason.
Language: lua

prev_keys = input.get() function lol() keys = input.get() if keys["shift"] then if keys["F1"] and not prev_keys["F1"] then print("Hey you saved state 1!") end end prev_keys = keys end gui.register(lol)
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.
Real96
He/Him
Joined: 3/19/2016
Posts: 15
feos wrote:
How? Here's my example but it doesn't fire consistently for some odd reason.
Language: lua

prev_keys = input.get() function lol() keys = input.get() if keys["shift"] then if keys["F1"] and not prev_keys["F1"] then print("Hey you saved state 1!") end end prev_keys = input.get() end gui.register(lol)
I was also thinking a something like that. Does it works?
Masterjun
He/Him
Site Developer, Skilled player (1987)
Joined: 10/12/2010
Posts: 1185
Location: Germany
The solution wasn't a solution to the generic problem of saving a value on a savestate. It was a solution to the specific problem which could be solved without that feature.
Warning: Might glitch to credits I will finish this ACE soon as possible (or will I?)
Real96
He/Him
Joined: 3/19/2016
Posts: 15
Masterjun wrote:
The solution wasn't a solution to the generic problem of saving a value on a savestate. It was a solution to the specific problem which could be solved without that feature.
Yes, exactly as it said