Post subject: Screenshot including lua graphics AND undetected lag frames
Player (160)
Joined: 10/21/2014
Posts: 62
Location: England
Hi all, I have two queries that are lua related. 1: Is it possible to take a screenshot that includes any lua drawn graphics? That would be a huge timesaver for what I'm working on, and from what I can tell it can't be done easily? The obvious approach (draw graphic, advance frame, take screenshot) doesn't seem to work, and I can understand that you wouldn't always want these graphics in a screenshot. Is there an alternative method I could use? Either way, I think having the option to include lua graphics in any taken screenshot would be a nice feature. 2: I'm TASing a fairly laggy game (Rayman: Hoodlums' revenge for GBA) and I'm trying to write some macros. To account for lag, when advancing the frame during the macro I can repeat if emu.islagged(), which works for most instances of lag, but on some occasions there are lag frames that go undetected. The frame number is accordingly not red (which I presume is the indicator for a non-input frame?), even though the game does not update during the frame. I'm pretty new to TASing, so I don't know if this is a common issue across other games, or some other type of lag I don't know about (perhaps those frames accept input but then ignore it for some reason?), but whatever the reason, can anyone suggest a way I might be able to detect those lag frames in a lua script? Thanks in advance for any help, and let me know if I should provide more details.
Player (144)
Joined: 7/16/2009
Posts: 686
1) You can enable (or disable) the capturing of Lua draw graphics and any other non-game screen elements by checking (or unchecking) File -> Screenshot -> Capture OSD. 2) The problem with lag frames is that whether a frame is laggy or not can only be determined after emulating the frame. The only way to detect lag in advance is by emulating a frame, seeing if it lagged, then going back. You can do this with Lua, if you really want to, by saving a state, emulating a frame, detecting whether there was lag and loading the state again. The better option, but arguably so and not always possible, is to have your script work based on memory values, like position, speed, hp or what have you.
Player (160)
Joined: 10/21/2014
Posts: 62
Location: England
Scepheo wrote:
File -> Screenshot -> Capture OSD.
Ah, cheers! I was sure I must be missing something simple. As for the lag, yeah fair enough. I considered that and have been stumbling through the memory trying to work out which values are which. I've not yet found anything I could use, but if I know it's really the only option then I'll redouble my efforts! As an aside, do you/anyone know if it's common in an isometric platformer to store the player's position only as co-ordinates along the diagonals? (i.e. Increasing when moving down-right, decreasing up-left, and the dual for down-left, up-right.) I guess it would make sense, and those are the only values I can find thus far, but it'll make what I'm trying to do (pinpoint the player's actual x/y position so I can mark it on a non-isometric map) a little trickier.
Player (144)
Joined: 7/16/2009
Posts: 686
For isometric games, I've seen both systems (along diagonals and along horizontal/vertical) used. I'd recommend just picking a direction to walk and look for an address that increases/decreases along with that. Regardless of the system used, this should find some coordinate related address, and then you can work from there. The transformations used to convert from isometric to orthogonal aren't super difficult, by the way. A quick Google should help you with that, as it's used very often, e.g. in isometric strategy games, to convert mouse clicks to in-game coordinates.
ALAKTORN
He/Him
Player (99)
Joined: 10/19/2009
Posts: 2527
Location: Italy
Working around the lag should be easy. Instead of using the emulator’s frame counter, look in RAM for a frame counter that does not update during lag (I think this usually is 2 frames behind the emu’s frame counter), and just use that address for your Lua to detect whether there was lag or not. I have no idea what you’re trying to do so maybe I’m wrong, but our Advance Wars: Dual Strike TAS bot uses the frame counter from RAM to avoid doing input during lag frames, so if it works there it should work for you. But still, don’t forget to try and do lag reduction optimization yourself.
Player (160)
Joined: 10/21/2014
Posts: 62
Location: England
Thanks a lot guys, I should be able to get what I want done now. (Or at least give it a good go!) In case you're interested, this video shows what I'm trying to do: https://www.youtube.com/watch?v=2i5gSqn0OoA The map on the right screen can be accessed in game by opening the menu, but it only shows the yellow cross marking Rayman's on-screen location (which is unhelpful when using that glitch), and does not show the more useful black cross marking the ground he is actually above (which in that video I manually added). I'm trying to automate both the creation of the maps and the adding of the cross showing Rayman's real location. I've got most of it working, and your suggestions should help me finish almost everything else off. The only remaining difficulty I can foresee is a way of getting the height the black x must be at (which is not always 0). I've found an address for Rayman's absolute height value, but what I really need is either height above nearest ground, or the height of the ground below him. If I can't find addresses for those then I'll work something else out. Anyway, thanks again!