Lua scripting support

Discuss anything about DraStic here.
Downsider
Posts:6
Joined:Thu Aug 15, 2013 2:41 pm
Lua scripting support

Post by Downsider » Thu Aug 15, 2013 2:48 pm

I think adding Lua scripting support would be great for Drastic, especially on devices such as the NVidia SHIELD.

Just have a few functions implemented, same stuff that FCEUX provides:

emu.frameAdvance() (Would have to be called in the script's main loop)
emu.skipFrame()

memory.readByte(location)
memory.writeByte(location, value)

input.readPad(index)
input.writePad(index, value)
input.readTouch(index) (For getting native touches on the screen)
input.writeTouch(x, y, pressed) (For putting the single NDS touch on the screen)

Would make it possible to play games like Metroid Prime: Hunters with dual analog controls, way better than doing it with fake touch inputs through sendevent or something. Especially since in Hunters, the screen doesn't move for a few frames after you initially press on the screen to prevent accidental movement with the stylus, and your fake touches from the second analog stick going off screen, that means that your aim would stall frequently.

We could override all of that stuff that would be bad with dual analog controls by just writing directly to memory.. I'm not 100% with how complex NDS games are, but because of the relatively weak specs, I imagine most things would reside in the same areas of memory for the entirety of the game, no crazy memory management stuff going on.

I'd be willing to write more than a few to improve the experience on the SHIELD for my favorite NDS games! ;)

EDIT:
Turns out DeSmuME already implements Lua scripts. Might be wise just to copy that API design so you can reuse those scripts.

User avatar
beansta
Posts:375
Joined:Wed Aug 07, 2013 9:39 pm

Re: Lua scripting support

Post by beansta » Thu Aug 15, 2013 4:43 pm

Or you could buy Universal BT/USB Joycenter on google play and its companion app Joy2touch free which can do the same function
Devices running Android:

- Samsung Galaxy Note 4 (CM12.1, overclocked, undervolted)
- Asus Nexus 7 2013 (Stock Marshmallow...to play Pokemon GO on...)
- Tenfifteen QW09 SmartWatch (Kitkat)
- Fujitsu Lifebook T4410 Touchscreen Laptop (Remix OS 3.0)

Downsider
Posts:6
Joined:Thu Aug 15, 2013 2:41 pm

Re: Lua scripting support

Post by Downsider » Thu Aug 15, 2013 6:41 pm

beansta wrote:Or you could buy Universal BT/USB Joycenter on google play and its companion app Joy2touch free which can do the same function
I appreciate you trying to help, albeit extremely rudely, but what you're suggesting is literally something I addressed in my post with the whole line about fake touch events with sendevent and how certain games don't behave in ways that agree with the extremely limited input options that those programs allow you to use. They don't perform the same function at all, one is an extremely limited drag-and-drop interface and one is a powerful scripting interface.

By implementing a scripting language with the ability to read/write from memory and foster touch inputs directly into the emulator, you side-step all those issues and reduce input latency. ;) You can also write interesting things such as cheats or game mods by manipulating memory in certain situations.

Exophase
Posts:1715
Joined:Mon Aug 05, 2013 9:08 pm

Re: Lua scripting support

Post by Exophase » Thu Aug 15, 2013 7:16 pm

Sorry, but I think something like this isn't too likely to happen in the near future. It's kind of a lot of work for something that not too many people would use. At the very least it'd be a low priority behind compatibility and other features, even DLDI support for homebrew. Don't get me wrong, the ideas you listed definitely sound cool. I know they were just specific examples and saying "well, we were thinking of adding a native capability for that" doesn't really serve as much of a justification, but I figured I'd tell you that we were planning on adding some of these native features anyway ;)

I'm not sure what other emulators out now are using for their Lua support but if they're using libraries under licenses like the GPL then that wouldn't really be an option for us. That is, unless we decide to go GPL ourselves (which would probably also mean dropping the charge for the emulator), which I don't think we're going to be doing any time soon.

Downsider
Posts:6
Joined:Thu Aug 15, 2013 2:41 pm

Re: Lua scripting support

Post by Downsider » Thu Aug 15, 2013 7:41 pm

Lua is MIT license, so that's not an issue. It's really only a day or two's work to bind a scripting language, but I'm sure you know that.

I'm not suggesting you write scripts dozens of scripts for games, I'm just suggesting you bind the scripting language and let the community write them. It would allow for complex control schemes.

I mean.. you added Google drive saving for Christ's sake. I'd rather have support for making the Ouya and NVidia SHIELD, or whatever other platform people use controllers on, a more viable platform. If you want I can implement it for you ;)

Exophase
Posts:1715
Joined:Mon Aug 05, 2013 9:08 pm

Re: Lua scripting support

Post by Exophase » Thu Aug 15, 2013 8:41 pm

I didn't know that it was MIT, thanks for informing me. In this case it is something we can look at later, but please be patient with us because we're swamped with a bunch of other things. I understand that you aren't expecting us to actually write any scripts.

Downsider
Posts:6
Joined:Thu Aug 15, 2013 2:41 pm

Re: Lua scripting support

Post by Downsider » Wed May 06, 2015 1:35 pm

Bumping this. I downloaded Drastic and was playing Okami today, and something as simple as hiding the buttons and switching to the bottom screen automatically when you have the paintbrush active would be incredible.

Exophase
Posts:1715
Joined:Mon Aug 05, 2013 9:08 pm

Re: Lua scripting support

Post by Exophase » Wed May 06, 2015 2:07 pm

I'll talk to Lordus about this and see how something like this would work and get an idea of how much impact it'll be to implement.

I'd also like to check with the DeSmuME delivers to make sure it's okay with them to reuse some or all of their API before doing so. Do you know if it's documented anywhere outside of the code?

And if we work on this, would you be willing to help us test it with some scripts?

User avatar
ericbazinga
Posts:1123
Joined:Mon Apr 13, 2015 6:46 pm
Location:Somewhere in VRchat
Contact:

Re: Lua scripting support

Post by ericbazinga » Wed May 06, 2015 3:48 pm

Downsider wrote:Bumping this. I downloaded Drastic and was playing Okami today, and something as simple as hiding the buttons and switching to the bottom screen automatically when you have the paintbrush active would be incredible.
Yeah, but if we implemented stuff like that for EVERY NINTENDO DS GAME EVER it would take YEARS.
Image

You can also find me on Reddit (u/Ericbazinga) and Discord (in the DraStic Discord server). You'll find me in those places almost daily and here almost never.

TkSilver
Posts:576
Joined:Wed Mar 25, 2015 3:30 am

Re: Lua scripting support

Post by TkSilver » Wed May 06, 2015 4:33 pm

ericbazinga wrote: Yeah, but if we implemented stuff like that for EVERY NINTENDO DS GAME EVER it would take YEARS.
Not every DS game needs a modified control scheme outside of the standard ones now provided. Also sadly not every DS game is popular or good enough that ppl still play it.

To be honest making more DS games more viable on more platforms is a wpnderful idea that hopefully will lead to more users. The added benefit of making the touch controls more customizable is also a nice touch since touch screen controls are less then ideal for a lot of different games. I think that this is a good long term goal with some possible upsides that might impact the average user more then DLDI support (which is still a great thing).

As far as the Okami example goes does the ds/ds game send any signal that it expects a touch screen input when something like that hapmind? Another example would be the seal tracing in castlevania, or even the pokemon battle systemmin 5th gen (white(2), black(2)) that is designed with touch in mind.

Post Reply