News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Feasibility of a Lua based real time game editor  (Read 1806 times)

RyanfaeScotland

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • My Brill Game Site
Feasibility of a Lua based real time game editor
« on: October 20, 2016, 03:03:53 pm »
As I continue to play with Lua on Gens my thoughts have turned towards the potential to make a real time level editor using it.

I wondered if anyone has attempted it before or if there are any examples already out there? (Search turned up some interesting post but nothing related.)

It doesn't have to be a level editor, a stat editor or similar would be good to see.

The important part here is I'm not just looking for something that can poke memory here and there as that is fairly straightforward. What I've got in mind is essentially you walk around the world as you normally would and there is an overlay that let's you change the values being used for the map. You tweak the values and the map updates real time, once done you hit save on the overlay and it writes out your map to a separate file, ready for you to import into the ROM.

Obviously that's pretty high level, editing memory real time may well crash the game, the output you get may not be able to insert directly back into the ROM as is and a slew of other issues but as a concept what do you think? And has it been done before?

Disch

  • Hero Member
  • *****
  • Posts: 2746
  • NES Junkie
    • View Profile
Re: Feasibility of a Lua based real time game editor
« Reply #1 on: October 20, 2016, 03:22:24 pm »
I think I get what you're saying.  And yeah it should be possible.  It's basically the same idea as NESticle's VROM editor (which I'm still surprised FCEUX doesn't have something similar).

For game specific edits, anything you can write an editor for you could probably write an in-game editor for.  The only difference is the editor would be interfacing with the emu through Lua instead of being a stand alone program.

As for whether or not it's been done before... I'm not aware of any.


Though I'm not sure this would be the best idea.  A better idea might be to have an editor have a "run" option -- where it makes a savestate, then launches the emu and loads the savestate so you can "jump" to the part of the game that has your changes.  Do the work in a dedicated editor --- but have the emu show you how it works in game.

mz

  • Sr. Member
  • ****
  • Posts: 441
  • Whore
    • View Profile
Re: Feasibility of a Lua based real time game editor
« Reply #2 on: October 20, 2016, 03:58:37 pm »
I'm pretty sure someone wrote something like this for Sonic 3 or something years ago, but TASVideos forums are a piece of shit and they're not indexed on Google, so it's impossible for me to find it now.
There has to be a better life.

RyanfaeScotland

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • My Brill Game Site
Re: Feasibility of a Lua based real time game editor
« Reply #3 on: October 20, 2016, 05:16:32 pm »
...A better idea might be to have an editor have a "run" option...

Hmm I quite like that, could be less error prone as well.

FAST6191

  • Hero Member
  • *****
  • Posts: 2621
    • View Profile
Re: Feasibility of a Lua based real time game editor
« Reply #4 on: October 20, 2016, 07:00:35 pm »
For my GBA/DS docs I pulled apart the level format for N+ and did a lot of stuff there in the live memory editor as I am far too lazy to edit and reboot the ROM a lot. I can't imagine lua, which you probably can direct to do it all at once and tied with proper timings, is going to make much odds there.
Main problem tends to be if the level is refreshed from the ROM (in my case the thumbnail was generated a while back but the background thumbnail of the level once highlighted and before you actually start was done such that my RAM edits were fine) or the level is streamed in some manner, however the workaround is the same as the instadeath avoidance when making infinite health cheats for RAM codes, or you add some if else logic -- all presumably well within the capability of anybody thinking about going down this path.

I might consider starting out on a single screen or at least very little scrolling game at first because of all that. If you are sticking with the megadrive I reckon it could spice bomberman up nicely.

jonk

  • Sr. Member
  • ****
  • Posts: 273
    • View Profile
Re: Feasibility of a Lua based real time game editor
« Reply #5 on: October 21, 2016, 12:39:52 am »
A better idea might be to have an editor have a "run" option -- where it makes a savestate, then launches the emu and loads the savestate so you can "jump" to the part of the game that has your changes.  Do the work in a dedicated editor --- but have the emu show you how it works in game.
That's pretty much what my son and I have been doing. We save the game state with BSNES+, which allows us to return exactly to the same moment on a restore. But just make some changes in the ROM first, then test out the results right away. I do change some visual details, but it's more been for changing game play and adding whole new sequences of user input and dialog popups. Mostly, adding a lot of assembly code and then testing it out.

So I think I get your thoughts about an editor that would work similarly to this mode of operation. But then the question arises for me. If there already are level editors around for some game/system, then it seems that this mode would already exist. The rest of the bits are already there for BSNES+, anyway. So if I add a level editor as a tool to my working directory, the rest just happens. Yes? Or am I missing something else?
An equal right to an opinion isn't a right to an equal opinion. -- 1995, me
Saying religion is the source of morality is like saying a squirrel is the source of acorns.  -- 2002, me

Disch

  • Hero Member
  • *****
  • Posts: 2746
  • NES Junkie
    • View Profile
Re: Feasibility of a Lua based real time game editor
« Reply #6 on: October 21, 2016, 12:51:41 am »
If there already are level editors around for some game/system, then it seems that this mode would already exist. The rest of the bits are already there for BSNES+, anyway. So if I add a level editor as a tool to my working directory, the rest just happens. Yes? Or am I missing something else?

The way I imagine it working if I were to design it would be to give the emu commandline args to load a ROM and immediately load a state.  So say you press F5 or whatever in the editor, it internally launches another process to start up the emu, give it the modified ROM, and give it a savestate to load.  The editor can then just hand over focus to the emu.

I'm not familiar with BSNES+ to know whether or not it has the necessary commandline args to make this happen that way.  It probably can accept a ROM name to auto-load, but the savestate option might not be there.  If not, the editor could try faking a hotkey press to get BSNES to load the state shortly after startup.

For the user, the end result is pressing F5 pops the emu up right in your face with the game and state loaded.

FuSoYa

  • Jr. Member
  • **
  • Posts: 19
    • View Profile
    • FuSoYa's Niche
Re: Feasibility of a Lua based real time game editor
« Reply #7 on: October 21, 2016, 04:18:32 am »
Another possibility is just integrating the emulator with the editor.  Lunar Magic for example allows loading Snes9x or BSNES via Alcaro's LMSW dll to draw directly within LM's level editing window.  It monitors the level tile layout in LM to pass on to the emulator, effectively making it possible to edit a SMW level as you play it.

LMSW's source is out there if you want to take a look at how that can be done.  While it's more work and the feasibility depends on the game, it can be fun to play around with.

RyanfaeScotland

  • Sr. Member
  • ****
  • Posts: 361
    • View Profile
    • My Brill Game Site
Re: Feasibility of a Lua based real time game editor
« Reply #8 on: October 25, 2016, 04:29:46 am »
Interesting thoughts, repurposing the emulator dlls to make a playable window in an editor sounds pretty creative too. Thanks for all the replies.

I was playing with Toejam & Earl again and sussed out the current level and item locations so although I know T&E isn't the game most in need of a level editor (Bomberman is a great choice) it's the one I'm interested in exploring just now so I think I'll give something a try with that.

The ability to add / remove items on the currently visable view shouldn't be too hard.