Post subject: Constant printing when frame advancing
Stovent
He/Him
Publisher
Joined: 8/23/2016
Posts: 165
Location: France
Hi, here is my problem : when I print a value with gui.text, it doesn't stay on screen, it disapear after a short time. Is it possible to let it printed even if the game is in pause ?
[17:37:00]<TheCoreyBurton> It's N64 - it's ALWAYS bad news.
Masterjun
He/Him
Site Developer, Expert player (2047)
Joined: 10/12/2010
Posts: 1185
Location: Germany
Quick solution for people that don't care why it works:
Language: lua

local function main() gui.text(10,10,"hi") end gui.register(main)
---------------- DeSmuME is interesting in that it constantly redraws the screen even when paused. I'm assuming your code looks like this:
Language: lua

while true do gui.text(10,10,"hi") emu.frameadvance() end
The point is that you are using the gui function once a frame, but the screen is redrawn multiple times per frame. The solution is to tell DeSmuME that you want to keep drawing when it draws the screen, with gui.register():
Language: lua

gui.register(function() gui.text(10,10,"hi") end)
Warning: Might glitch to credits I will finish this ACE soon as possible (or will I?)
Stovent
He/Him
Publisher
Joined: 8/23/2016
Posts: 165
Location: France
My code was :
Language: lua

function main() gui.text(0, -10, emu.framecount() + 18) end emu.registerafter(main)
but thank you, it works as I wanted Can you explain me was does the register function does or, at least, a link to the explanation ? I wanna understand
[17:37:00]<TheCoreyBurton> It's N64 - it's ALWAYS bad news.
Masterjun
He/Him
Site Developer, Expert player (2047)
Joined: 10/12/2010
Posts: 1185
Location: Germany
Unfortunately the Lua in DeSmuME is not really well documented. This file in the code tells me that we have emu.register, emu.registerbefore, emu.registerafter, emu.registerstart, and emu.registerexit. I'd assume registerexit will execute when the Lua script exits, and registerstart when the game starts up. According to this other file the others go in this order after the start of a frame (like, when you press the frameadvance key):
    emu.registerbefore <actual emulation of the frame> emu.registerafter emu.register
And then (when paused) it idles repeatedly doing this:
    <wait 50 ms> emu.register
(So you have a maximum of 20 calls per second when paused, which I confirmed is indeed the case.)
Warning: Might glitch to credits I will finish this ACE soon as possible (or will I?)
Stovent
He/Him
Publisher
Joined: 8/23/2016
Posts: 165
Location: France
Ok, thank you for your help ! :)
[17:37:00]<TheCoreyBurton> It's N64 - it's ALWAYS bad news.