1 2
13 14
Darth_Marios
He/Him
Joined: 5/11/2015
Posts: 109
YoshiRulz wrote:
Darth_Marios wrote:
By the way, how to "convert" a code that start with 10xxxxxx? The cheat type says: 10aaaaaa dddd ;-16bit Increment [aaaaaa]=[aaaaaa]+dddd but i dont have any idea how a lua script would look about that...
Just based on what you've said, memory.write_u16_le(a, memory.read_u16_le(a) + d).
Thanks! (I'm still quite a noob with lua)
Editor, Expert player (2330)
Joined: 5/15/2007
Posts: 3933
Location: Germany
I'm trying to read cpu registers for Game Boy (A, B, C, D, E, H, L). The Bizhawk Lua Functions page says to use
emu.getregisters()
to get the register names, but it just returns an empty table. On Bizhawk 2.8.
YoshiRulz
Any
Editor, Emulator Coder
Joined: 8/30/2020
Posts: 106
Location: Sydney, Australia
MUGG wrote:
I'm trying to read cpu registers for Game Boy (A, B, C, D, E, H, L). The Bizhawk Lua Functions page says to use
emu.getregisters()
to get the register names, but it just returns an empty table. On Bizhawk 2.8.
CNR, all 3 cores implement registers. Do you have a rom loaded?
I contribute to BizHawk as Linux/cross-platform lead, testing and automation lead, and UI designer. This year, I'm experimenting with streaming BizHawk development on Twitch. nope Links to find me elsewhere and to some of my side projects are on my personal site. I will respond on Discord faster than to PMs on this site.
Hey look buddy, I'm an engineer. That means I solve problems. Not problems like "What is software," because that would fall within the purview of your conundrums of philosophy. I solve practical problems. For instance, how am I gonna stop some high-wattage thread-ripping monster of a CPU dead in its tracks? The answer: use code. And if that don't work? Use more code.
Editor, Expert player (2330)
Joined: 5/15/2007
Posts: 3933
Location: Germany
I would like to update my old luascript so it can run on newer Bizhawk.
while true do

--...

    if client.ispaused() then
		gui.DrawFinish()
		emu.yield()
	else
		emu.frameadvance()
	end
end
The emulator prints that gui.DrawFinish() is deprecated. This line was needed to update the screen while the emulator is paused. I couldn't find a replacement for this function. How should I change the code to achieve the desired effect (updating the screen while the emulator is paused)?
Emulator Coder, Judge, Experienced player (729)
Joined: 2/26/2020
Posts: 783
Location: California
Just don't include the line, drawing will still occur regardless.
Editor, Expert player (2330)
Joined: 5/15/2007
Posts: 3933
Location: Germany
The script in question is my Kirby & The Amazing Mirror luascript and I'm testing in Bizhawk 2.9.1 on the (U) or (J rev 1.1) version. First, I replaced all instances of table.getn(mytable) with #mytable to make it run in the first place. While the emulator is paused, I'm expecting to be able to navigate the little menu I have drawn on screen via my script by mouse-click. After removing the line gui.DrawFinish, this is not possible anymore, even on Bizhawk 2.9.1. The line works fine under Bizhawk 2.9.1, but the emulator would keep printing in the console that it's deprecated, slowing performance. I would be grateful for a replacement function or to be able to disable the console messages. I might look into other ways, such as lua canvas. Thank you.
Emulator Coder, Judge, Experienced player (729)
Joined: 2/26/2020
Posts: 783
Location: California
gui.drawFinish just does nothing in modern (since 2.5 iirc?) BizHawk versions (besides putting the deprecated message, which you can get rid of by just not calling that function). Drawing a surface "starts" whenever a draw commands happens in a new frame and "ends" once that frame ends and there was a start to begin with, more or less (the exact logic is complicated and also wouldn't work with multiple scripts). The latest dev builds anyways have simplified the behavior and might end up solving your issue?
Editor, Expert player (2330)
Joined: 5/15/2007
Posts: 3933
Location: Germany
Hmm, this is odd. I tested again with the removed line and now it works, mysteriously... Ok, the problem is solved. Thank you and sorry for the confusion.
Editor, Expert player (2330)
Joined: 5/15/2007
Posts: 3933
Location: Germany
I have run into a different issue. When event.onloadstate() is called, it seems client extra padding set via client.SetGameExtraPadding() resets to 0. I have found nothing in my script that could be causing this. As a work-around I refresh the extra padding, but it is annoying to see the window resize every time I load a state. The script in question: https://tasvideos.org/Forum/Topics/2095?CurrentPage=9&Highlight=530445#530445
Emulator Coder, Judge, Experienced player (729)
Joined: 2/26/2020
Posts: 783
Location: California
As far as I can tell there's nothing in BizHawk that could even be causing such behavior. Is the same behavior present in dev builds?
Editor, Expert player (2330)
Joined: 5/15/2007
Posts: 3933
Location: Germany
CasualPokePlayer wrote:
As far as I can tell there's nothing in BizHawk that could even be causing such behavior. Is the same behavior present in dev builds?
I'm not sure what to say. Because I reopened the emulator and the issue "fixed itself", once again. Maybe something is wrong about reloading luascripts. When making changes to a luascript, it seems the emulator has to be reopened and the script run from a fresh start, in order to fix obscure issues.
Site Admin, Skilled player (1254)
Joined: 4/17/2010
Posts: 11478
Location: Lake Char­gogg­a­gogg­man­chaugg­a­gogg­chau­bun­a­gung­a­maugg
Clearing registered functions would have the same effect as closing the emu (right-click menu on lua console).
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.
Editor, Expert player (2330)
Joined: 5/15/2007
Posts: 3933
Location: Germany
How can I let a movie play back in TAStudio while applying input on the go via lua?
Language: Lua

-- this code isn't working myjoypad = joypad.getwithmovie() if myjoypad.Left then local random_num = math.random() local apply_change = false if random_num < 0.1 then myjoypad.Right = true apply_change = true elseif random_num > 0.9 then myjoypad.Up = true apply_change = true end if apply_change then tastudio.setrecording(true) joypad.set(myjoypad) tastudio.applyinputchanges() tastudio.setrecording(false) end end
EDIT: Nvm, here is working code I figured out.
Language: Lua

myjoypad = joypad.getwithmovie() if myjoypad.Left then local random_num = math.random() if random_num < 0.1 then tastudio.submitinputchange(emu.framecount(), "Right", true) tastudio.applyinputchanges() elseif random_num > 0.9 then tastudio.submitinputchange(emu.framecount(), "Down", true) tastudio.applyinputchanges() end end
Emulator Coder, Judge, Experienced player (729)
Joined: 2/26/2020
Posts: 783
Location: California
joypad.set only works while recording mode is enabled (as it mimics native input, not painting inputs and such).
Editor, Expert player (2330)
Joined: 5/15/2007
Posts: 3933
Location: Germany
How can I make my script stop? I have not found a function for this. Only functions that close the rom or close the emulator. When I close the ROM, my luascript spits out errors in the console and I want to avoid that. Another question. I noticed the lua console said "Message Cap reached, suppressing output" because of a long string that was outputted. I don't think this happened on older Bizhawk. Is there a way to disable this?
Editor, Expert player (2073)
Joined: 6/15/2005
Posts: 3282
MUGG wrote:
I noticed the lua console said "Message Cap reached, suppressing output" because of a long string that was outputted.
From my experience, that can definitely happen if you do too many console.write operations without emu.frameadvance(). The Lua console is not a good way of holding output long-term. Try output to file, something like:
local f = io.open("results.txt","a")
    f:write( ... )
f:close()
(replace "..." with whatever string you want to output) Edit: The error happens if you use console.write 100 or more times in a row. You can make your output string first (use ".." (two dots) to concatenate the strings all together), then at the end use console.write on that string. Of course, if you are storing output that you want to view long-term, better to output to file as shown above.
YoshiRulz
Any
Editor, Emulator Coder
Joined: 8/30/2020
Posts: 106
Location: Sydney, Australia
MUGG wrote:
How can I make my script stop?
return; from the top level (or break; out of your infinite loop and let it run to EOF).
I contribute to BizHawk as Linux/cross-platform lead, testing and automation lead, and UI designer. This year, I'm experimenting with streaming BizHawk development on Twitch. nope Links to find me elsewhere and to some of my side projects are on my personal site. I will respond on Discord faster than to PMs on this site.
Hey look buddy, I'm an engineer. That means I solve problems. Not problems like "What is software," because that would fall within the purview of your conundrums of philosophy. I solve practical problems. For instance, how am I gonna stop some high-wattage thread-ripping monster of a CPU dead in its tracks? The answer: use code. And if that don't work? Use more code.
1 2
13 14