Post subject: Help with LUA @ Mame-RR
Experienced Forum User
Joined: 8/16/2018
Posts: 6
Hello community, A friend called peon2 is working on a training mode for jojoban with FBA, but I want to port it to MAME because it is more comfortable to me. The problem I am facing is that I don't know what the internal inputs names are for the buttons, How can I check it? I did check the .cfg, used it in the LUA script but still doesn't read the input (I want to show an image with the pressed key). Direction inputs are working, but the rest of the buttons (button 1, start, coin...) are not. Thank you!
Experienced Forum User, Site Admin, Skilled player (1177)
Joined: 4/17/2010
Posts: 10943
Location: RU
I don't know for sure, but I think the button names for your game can be seen in the input config dialog that you can access by pressing Tab with the game running. Otherwise, here's some wiki originally written by mz and dammit: https://github.com/TASVideos/mame-rr/wiki/Lua-scripting-functions
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. If TASing is meta-play, TASVideos Movie Rules are meta-meta-play!
Experienced Forum User
Joined: 8/16/2018
Posts: 6
feos wrote:
I don't know for sure, but I think the button names for your game can be seen in the input config dialog that you can access by pressing Tab with the game running. Otherwise, here's some wiki originally written by mz and dammit: https://github.com/TASVideos/mame-rr/wiki/Lua-scripting-functions
Thank you. I tried with with the same names (P1 Button 1, Button 1, Button1, P1Button1, Button_1, and so on...) and none worked.
Experienced Forum User, Site Admin, Skilled player (1177)
Joined: 4/17/2010
Posts: 10943
Location: RU
Are you sending their names as strings?
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. If TASing is meta-play, TASVideos Movie Rules are meta-meta-play!
Experienced Forum User
Joined: 8/16/2018
Posts: 6
Thank you again! I have try print (joypad.get()) and I get the values, replaced those and now it is working! Now I am having a damn strange bug, but I will repost it when the lua hit the public (now it is a private beta).
Experienced Forum User
Joined: 8/16/2018
Posts: 6
Ok so he gives me permission to ask this. Basically the problem is: The script have a record mode. You push the record button (Button 5 in this case) move around and then, you can push Button 5 again for stop recording or Button 6 for replay. The thing that MAME register and save everything but not Button 4 for some unknown reason. All the syntax and names are 100% correct so we don't know where is exactly the problem. Sorry for the double post!
Experienced Forum User, Site Admin, Skilled player (1177)
Joined: 4/17/2010
Posts: 10943
Location: RU
Are you using in-game buttons to control emulator behavior? If so, the input library should be used instead, see the bottom of the wiki (anchor link doesn't work for some reason).
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. If TASing is meta-play, TASVideos Movie Rules are meta-meta-play!
Experienced Forum User
Joined: 8/16/2018
Posts: 6
This is the inputs definition section:
	if gameinputs["P1 Left"] then
		P1inputs=P1inputs+1
	end
	if gameinputs["P1 Down"] then
		P1inputs=P1inputs+3
	end
	if gameinputs["P1 Right"] then
		P1inputs=P1inputs+5
	end
	if gameinputs["P1 Up"] then
		P1inputs=P1inputs+10
	end
	if gameinputs["P1 Button 4"] then
		P1inputs=P1inputs+20
	end
	if gameinputs["P1 Button 3"] then
		P1inputs=P1inputs+40
	end
	if gameinputs["P1 Button 2"] then
		P1inputs=P1inputs+80
	end
	if gameinputs["P1 Button 1"] then
		P1inputs=P1inputs+160
	end
Is there any other possible workaround?
Experienced Forum User
Joined: 8/16/2018
Posts: 6