News: 11 March 2016 - Forum Rules

Author Topic: Any "How to make LUA Scripts on DeSmuME for dumbs"?  (Read 8195 times)

Tsukiyomaru0

  • Sr. Member
  • ****
  • Posts: 416
  • I have no regrets!
    • View Profile
Any "How to make LUA Scripts on DeSmuME for dumbs"?
« on: September 11, 2016, 11:08:39 am »
Looked everywhere, they were all confusing. The reason I want is because I was thinking of creating a script to be able to use a XB360 gamepad (and also add notes as for what entries needs to be changed and how to make it work with other controllers) on the game Metroid Prime Hunters, however I could find nothing. So, if anybody can help me grasp this language I'd be grateful.

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Any "How to make LUA Scripts on DeSmuME for dumbs"?
« Reply #1 on: September 11, 2016, 11:47:35 am »
The Lua language is simple enough -- the hard part is the API DeSmuME provides -- I can't find a shred of documentation on it.  How do they expect people to write scripts if they don't publish an API?

The most I can find is they say "look at FCEUX Lua" in the FAQ, so I can only assume it mirror's FCEUX's API, which is documented here:

http://www.fceux.com/web/help/fceux.html?LuaScripting.html


But it can't possibly match exactly.  Maybe this is something you should ask on the DeSmuME forums.


As for using a 360 gamepad -- I'm appauled that an emulator doesn't support that out of the box.  Regardless, to accomplish that in Lua, you'll probably have to do the following:

1)  Import a package that allows for gamepad reads
2)  Register some kind of callback so the emu calls into your script every frame
3)  In that callback function, poll the gamepad to see what buttons are being pressed, and send that information to the emu (I would assume the Lua API provides a way to do this ... in FCEUX you can do it with joypad.set() )

Tsukiyomaru0

  • Sr. Member
  • ****
  • Posts: 416
  • I have no regrets!
    • View Profile
Re: Any "How to make LUA Scripts on DeSmuME for dumbs"?
« Reply #2 on: September 11, 2016, 11:41:23 pm »
So I'm in a tight spot,right?

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Any "How to make LUA Scripts on DeSmuME for dumbs"?
« Reply #3 on: September 11, 2016, 11:58:58 pm »
The hardest parts are finding the API for the emulator, and finding a package to read controller input.  Once you have those two things, using them is pretty straightforward, and I (or someone else on these boards) should be able to help you through it.

DeSmuME's API must be published somewhere... otherwise it'd be completely unusable.  Like I said... if you ask on that emu's forums, someone should be able to direct you to something you can use.

As for the package, that might be trickier... as I'm not even sure if one exists.  What you want is a general Lua package for getting controller input -- it doesn't have to be specifically for DeSmuME.  And in fact, there probably isn't something specifically for DeSmuME.



Of course... you might not need Lua for this.  If all you want is to be able to play DeSmuME with a controller, a program like JoyToKey should suffice.

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7260
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Any "How to make LUA Scripts on DeSmuME for dumbs"?
« Reply #4 on: September 12, 2016, 10:23:30 am »
Does it not support game controllers out of the box, or are 360 controllers just extra work to support? (I do recall byuu writing about needing to right some extra code in Higan/bsnes for the 360 controllers for something)
"My watch says 30 chickens" Google, 2018

FAST6191

  • Hero Member
  • *****
  • Posts: 3357
    • View Profile
Re: Any "How to make LUA Scripts on DeSmuME for dumbs"?
« Reply #5 on: September 12, 2016, 12:28:44 pm »
I have not implemented it in any code but from my XP machine on up it was plug and play with anything that spoke to the directX API and the standard controller for many many games on the PC. At this point I can't recall using it on windows in desmume, however it has worked in so many things I am fairly sure never got updated to handle such things. That said http://tasvideos.org/LuaScripting/TableKeys.html mentions a joypad lib version so who knows.

As far as I am aware the lua stuff was chosen to mirror fceux, a nice script for fceux for covering some real world stuff is
http://www.romhacking.net/forum/index.php?topic=18717.0

Otherwise have a poke around tool assisted speedrun videos as they are the main users of such things
http://tasvideos.org/LuaScripting.html

That said whatever the kids are using for a joypad to keyboard emulator this week (I tried to keep up but failed, though usually the worst is you get some adware), maybe combined with a mouse jail will hopefully get you what you want here.

Bahamut ZERO

  • Hero Member
  • *****
  • Posts: 903
    • View Profile
Re: Any "How to make LUA Scripts on DeSmuME for dumbs"?
« Reply #6 on: September 12, 2016, 08:26:25 pm »
DeSuMe supports Rock Candy 360 USB controllers, if you doon't care that it has a wire (I prefer it, myself).

As for the touch-based stuff (which I'm assuming you're trying to get to work with the controller since you're talking about Metroid Prime Hunters), you could probably rig the mouse controls to Joypad if you get desperate.

Hell, if it's the touchscreen part that's throwing you off, maybe there's a hack or cheatcode out there that'll map the aiming mechanics to buttons? Would make it harder to aim, but easier for you to map out to a joypad.
Like Super Mario Land? Then you'll love my first completed Rom Hack: Maniac on the Run!