cheat lua plugins

This forum is for making announcements about updated cheat files (for any emulator), updated web pages and of course about improvements to the MAME/MESS cheat engine.
Post Reply
crazyc
Posts: 31
Joined: Sat Apr 30, 2016 4:49 pm

Re: cheat lua plugins

Post by crazyc »

>Suppose we obtain only a result............ on result i can select... i have pick a screenshot:

The numbers there are address, value 1, value 2 (value 1 is the right operand and value 2 the left). Notice is says "Value is difference" which means it will only get matches that differ by the value, you put any which is why you got all the data that decreased. If you make value 1 then it will only show those that decreased by 1. If you choose "eqv" as the operator then it will only show those addresses that are equal to one.

>I can't do anythigs.... it's a BUG in current supports ?

Get https://raw.githubusercontent.com/mamed ... d/init.lua and put it in your plugins/cheatfind directory.
DjDiabolik
Posts: 4
Joined: Sun Oct 15, 2017 6:18 pm

Re: cheat lua plugins

Post by DjDiabolik »

Right now i have do a little better solution... i have "sync" the two folder "cheat" and "cheatfind" on my pc whit same exact files on github dev (i have found a site can download both folder from github in a zip) and now apparently the "cheat" and "cheatfind" it's works.... now i can use the "TEST" "WRITE" but i can't understand what's mean of "WATCH" feature...

Otherwise now when i press enter on "cheatfind" i can activate or not on "cheat" for make test and if it's the correct value example for life....... but if not from "cheat" you can add somethigs for delete an "entry" ??

Otherwise the "write" feature save a .xml and a file .json (?? because a file json? for a cheat it's not need only the .xml?)........... but from "cheat" plugins i thinks it's a good idea to add somethigs to save the "rom" xml example i play rom called astro.zip the write can save a file called astro.xml or somethigs similar. Right now apparently the write feature present some problems because i obtain an errors on second time i load the same games and after i found the correct "address" we need manually to rename and manage the .xml file directly from "Windows Explorer"....

Meanwhile now apparently all works.........
crazyc
Posts: 31
Joined: Sat Apr 30, 2016 4:49 pm

Re: cheat lua plugins

Post by crazyc »

Watch will display the real time value of a given address so you can watch how it changes as you play.
User avatar
Pugsy
Posts: 3679
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: cheat lua plugins

Post by Pugsy »

Just a quick observation

sfiii3 Hit Anywhere cheat doesn't work in the plugins cheat engine. It writes to the decrypted opcode region.

It's an odd one as it's a ROM cheat that needs to be enabled before you start the first round or it won't work, with o region cheats it doesn't matter...normally.
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
User avatar
Pugsy
Posts: 3679
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: cheat lua plugins

Post by Pugsy »

Split some posts here to
viewtopic.php?f=2&t=12478

As it was in danger of going too much off topic..
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
AlterEgo
Posts: 0
Joined: Thu Oct 11, 2018 5:49 pm

Re: cheat lua plugins

Post by AlterEgo »

Hi to all, new user and first post here ;)
One question about LUA script and Cheats: is it possible to enable a certain cheat (for example infinite lives or invincibiliy) by default during or after game loading without needing to set it manually or with assigned hotkey? If yes, where can i find a tutorial or any useful info about LUA scripts and how to create them? May you give me some suggest about how to do this task?
Thanks in advance! :)
User avatar
Pugsy
Posts: 3679
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: cheat lua plugins

Post by Pugsy »

Hi Carl

I've been modifying the cheat finder init.lua to get rid of the errors I keep making when using it and make it more suitable to the way I work. Unfortunately, there's a few issues I have because LUA confuses me - too different from C for me really.

https://pastebin.com/hYVz7r51

Anyway the changes I've made:

1. The "current" keeps tripping me up as unless you remember to save it to a slot you end up screwing up the search. So I've got rid of it the best I could...so it forces me to save to a slot before I can use it.
2. I've changed the way it displays the expression...makes it quicker to understand at a quick glance.
3. I've made it save an extra line to cheat.simple - basically the old dat format. I still use this to make cheats as my cheat release builder will handle the XML conversion.

The problem I have is with 2, it displays a line like "Perform Compare : Slot 1 < Slot 2" on the menu which works great if I change the opsel or value fields but it seems to be one update behind if i change the leftop/rightop or execute the "Save Current Memory" line. Is there a way of fixing this, please?

https://pastebin.com/hYVz7r51

BTW: Is there anyway of adding an extra command at the bottom of the cheat finder menu to allow the game to get paused whenever the cheat finder menu is on screen and unpauses when the TAB key is pressed. When using the debugger search pause/unpause is automatic and it was incredibly handy.

Pause Mode:
Automatically Pause/Unpause (default)
None

Cheers
Pugsy
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
crazyc
Posts: 31
Joined: Sat Apr 30, 2016 4:49 pm

Re: cheat lua plugins

Post by crazyc »

Pugsy wrote: Fri Dec 21, 2018 11:10 am The problem I have is with 2, it displays a line like "Perform Compare : Slot 1 < Slot 2" on the menu which works great if I change the opsel or value fields but it seems to be one update behind if i change the leftop/rightop or execute the "Save Current Memory" line. Is there a way of fixing this, please?
You want get set the leftop_text in the menu_callback function. Something like this

Code: Select all

menu[#menu + 1] = function()
	local m = { _(leftop), "", 0 }
	menu_lim(leftop, 1, #menu_blocks[1], m)
	m[1] = "Slot " .. leftop
	return m, function(event) local r leftop, r = incdec(event, leftop, 1, #menu_blocks[1]) leftop_text = "Slot " .. leftop return r end
end
You can also put the leftop/rightop display function above the "Perform Compare" one but this is more flexible because it's position independent.
crazyc
Posts: 31
Joined: Sat Apr 30, 2016 4:49 pm

Re: cheat lua plugins

Post by crazyc »

Pugsy wrote: Fri Dec 21, 2018 11:10 am BTW: Is there anyway of adding an extra command at the bottom of the cheat finder menu to allow the game to get paused whenever the cheat finder menu is on screen and unpauses when the TAB key is pressed. When using the debugger search pause/unpause is automatic and it was incredibly handy.
I added a menu cancel to the lua menu callback so add emu.pause() to the start of menu_populate and emu.unpause() to menu_callback like this

Code: Select all

local menu_is_showing = false

local function menu_populate()
	emu.pause()
	menu_is_showing = true
	local menu = {}
...
local function menu_callback(index, event)
	if event == "cancel" then
		emu.unpause()
		menu_is_showing = false
		return {0,0,0}
	end
	return menu_func[index](event)
end
...
emu.register_periodic(function ()
		if menu_is_showing and not manager:ui():is_menu_active() then
			emu.unpause()
			menu_is_showing = false
		end
	end)
The downside is that if you tab out of the menu then reenter it wont pause until you change something.
User avatar
Pugsy
Posts: 3679
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: cheat lua plugins

Post by Pugsy »

Thanks, for the both of those posts. You've saved me days of smacking my head against a wall!

I've managed to get it to pause automatically on re-entering. Not ideal as its sneaked it into the frame routine - bit of a hack but it works well.

I'm still having problems getting the "Perform Compare: LHS EXP RHS" to match the LHS, EXP & RHS entries beneath it.
It's only a problem when the "Save Current Memory State" line is used and it updates the LHS and/or RHS beneath it won't reflect in the Perform Compare line unless I manually change the RHS/LHS or just press up 14 times or down 9 times. A solution or a pointer would be great (a solution would be better - I'm not proud and I know my limitations!).

https://pastebin.com/5caJSxvE


BTW, I've just noticed in the proper init.lua when you save a 32 bit value, it's ok in the JSON file but in cheat.simple it comes through as nil rather than d, and in the xml it comes through as ppnil rather than ppd (or pd, as pp==p).
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
crazyc
Posts: 31
Joined: Sat Apr 30, 2016 4:49 pm

Re: cheat lua plugins

Post by crazyc »

Pugsy wrote: Sat Dec 22, 2018 5:48 pm I'm still having problems getting the "Perform Compare: LHS EXP RHS" to match the LHS, EXP & RHS entries beneath it.
It's only a problem when the "Save Current Memory State" line is used and it updates the LHS and/or RHS beneath it won't reflect in the Perform Compare line unless I manually change the RHS/LHS or just press up 14 times or down 9 times. A solution or a pointer would be great (a solution would be better - I'm not proud and I know my limitations!).
Set leftop_text and rightop_text in the "Save Current Memory State to Slot " function like

Code: Select all

				local function f(event)
					if event == "select" then
						for num, region in ipairs(devtable[devcur].ram) do
							menu_blocks[num][#menu_blocks[num] + 1] = cheat.save(devtable[devcur].space, region.offset, region.size)
						end
						manager:machine():popmessage(_("Memory State saved to Slot ").. #menu_blocks[1])
						if (leftop == #menu_blocks[1] - 1 and rightop == #menu_blocks[1] - 2 ) then
							leftop = #menu_blocks[1]
							rightop = #menu_blocks[1]-1
						elseif (leftop == #menu_blocks[1] - 2 and rightop == #menu_blocks[1] - 1 ) then
							leftop = #menu_blocks[1]-1
							rightop = #menu_blocks[1]
						elseif (leftop == #menu_blocks[1] - 1 ) then
							leftop = #menu_blocks[1]
						elseif (rightop == #menu_blocks[1] - 1) then	
							rightop = #menu_blocks[1]
						end
						leftop_text = "Slot " .. leftop
						rightop_text = "Slot " .. rightop
						devsel = devcur
						return true
					end
				end
or pd, as pp==p
Be careful here. It may be true for most stuff but as emulated machines with MMUs become more common it will get less so.
crazyc
Posts: 31
Joined: Sat Apr 30, 2016 4:49 pm

Re: cheat lua plugins

Post by crazyc »

Pugsy wrote: Sat Dec 22, 2018 5:48 pm BTW, I've just noticed in the proper init.lua when you save a 32 bit value, it's ok in the JSON file but in cheat.simple it comes through as nil rather than d, and in the xml it comes through as ppnil rather than ppd (or pd, as pp==p).
Fixed at https://github.com/mamedev/mame/commit/ ... 93b0a67a66.
User avatar
Pugsy
Posts: 3679
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: cheat lua plugins

Post by Pugsy »

crazyc wrote: Set leftop_text and rightop_text in the "Save Current Memory State to Slot " function like
Thanks, could not see the issue to save my life.
Pugsy wrote: or pd, as pp==p
crazyc wrote: Be careful here. It may be true for most stuff but as emulated machines with MMUs become more common it will get less so.
Facepalm, lpd = pd of course.

However, looking at this in more detail it's going to be really confusing for the games in the cheat collection with cheats already. All cheats in the cheat collection are logical and theres less than 100 physical pokes where the logical address is the same anyway.

For instance existing credits in kinst is maincpu.pb@8808F3E8=63 ( or maincpu.lpb@8808F3E8=63 ) and this address alone can be found with the debugger cheat search, however maincpu.ppb@808F3E8=63 is the address found with the LUA cheat finder.

8808F3E8 can be edited in the memory viewer, whilst 808F3E8 just shows **** and cannot be edited.

Yet wp 808F3E8,1,w gets hit and wp 8808F3E8,1,w doesn't.

Confusing....though it does give a better understanding of the memory in the various midway games like the kinst and mk series which have always been problematical as the memory handling in MAME for them as changed umpteenth times over the years.
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
User avatar
Pugsy
Posts: 3679
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: cheat lua plugins

Post by Pugsy »

Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
crazyc
Posts: 31
Joined: Sat Apr 30, 2016 4:49 pm

Re: cheat lua plugins

Post by crazyc »

Pugsy wrote: Sun Dec 23, 2018 2:31 am 8808F3E8 can be edited in the memory viewer, whilst 808F3E8 just shows **** and cannot be edited.

Yet wp 808F3E8,1,w gets hit and wp 8808F3E8,1,w doesn't.
Watchpoints only trigger on physical addresses because the translation occurs in the cpu device before it access is matched and translating the other way is very difficult. You can switch the memory editor to physical addresses in the options menu.
Pugsy wrote: Sun Dec 23, 2018 2:31 am For instance existing credits in kinst is maincpu.pb@8808F3E8=63 ( or maincpu.lpb@8808F3E8=63 ) and this address alone can be found with the debugger cheat search, however maincpu.ppb@808F3E8=63 is the address found with the LUA cheat finder.
I think that it makes more sense for the cheats to default to physical addresses rather than virtual ones but that's just IMO.
User avatar
Pugsy
Posts: 3679
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: cheat lua plugins

Post by Pugsy »

Thanks, I'd forgotten about the memory editor option.

Going forward any new RAM cheats I make will be physical addresses, I intend on using the LUA cheat finder for making RAM cheats so it'll be a given.

Thanks for the help.

Just found another bug maybe, if I do a byte search and then change to little u16 or big u16 it doesn't change the address to a word boundary (34286) and the endianness doesn't seem to change for one to w,6300.

jaguar/aircars94,:dsp,34287,b,63,Infinite Ammo <--u8
jaguar/aircars94,:dsp,34287,w,63,Infinite Ammo <--little u16
jaguar/aircars94,:dsp,34287,w,63,Infinite Ammo <--big u16

Don't know if it's just a feature as I would normally decide at the start of the search if it was a byte or a word and there is no pop-up warning about changing it mid-search.
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
crazyc
Posts: 31
Joined: Sat Apr 30, 2016 4:49 pm

Re: cheat lua plugins

Post by crazyc »

It not a feature or a bug it's really just an artifact of the way it works. The values to save are generated when the search is done and if you want to save in a different format you have to rerun the search (you can use the saved data so that doesn't need to be recreated).
User avatar
Pugsy
Posts: 3679
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: cheat lua plugins

Post by Pugsy »

I've been using the modified lua for about a month and it all works really well (it stopped the silly errors I kept making). I just noticed the latest change to init.lua and figured it might be worthwhile on getting some or all of the changes added to the official - so that I don't have to manually update my own init.lua everytime it changes.

However, I don't want to step on any toes and to be completely honest the only programming languages I am really proficient in are C and assembler I really don't know my changes/hacks conform to the LUA standard for mame.

Any chance you could have a look over the init.lua and change anything that is wrong or you don't agree with?

https://pastebin.com/d8ZwkX9P

Thanks


BTW, is is possible to move the cheat and cheatfinder from plugins and replace the existing Cheat Menu. It seems silly to have two lots of cheat menus especially as the plugin cheat menu is better and the cheatfinder will become more visible.....and if there are bugs with it then they are more likely to be found with more eyes on it.
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
crazyc
Posts: 31
Joined: Sat Apr 30, 2016 4:49 pm

Re: cheat lua plugins

Post by crazyc »

Pugsy wrote: Sun Jan 27, 2019 3:42 pm I've been using the modified lua for about a month and it all works really well (it stopped the silly errors I kept making). I just noticed the latest change to init.lua and figured it might be worthwhile on getting some or all of the changes added to the official - so that I don't have to manually update my own init.lua everytime it changes.
Haze has been using the cheat finder recently so I've pointed him here for some feedback.
Pugsy wrote: Sun Jan 27, 2019 3:42 pm However, I don't want to step on any toes and to be completely honest the only programming languages I am really proficient in are C and assembler I really don't know my changes/hacks conform to the LUA standard for mame.

Any chance you could have a look over the init.lua and change anything that is wrong or you don't agree with?
The only thing that stands out is to use string.format in things like line 564 for languages which the number shouldn't be placed at the end for a proper translation.
Pugsy wrote: Sun Jan 27, 2019 3:42 pm https://pastebin.com/d8ZwkX9P

Thanks


BTW, is is possible to move the cheat and cheatfinder from plugins and replace the existing Cheat Menu. It seems silly to have two lots of cheat menus especially as the plugin cheat menu is better and the cheatfinder will become more visible.....and if there are bugs with it then they are more likely to be found with more eyes on it.
Not really my call, frankly your opinion would carry more weight here than mine IMO.
User avatar
Pugsy
Posts: 3679
Joined: Fri Aug 17, 2001 12:59 am
Location: North Wales, UK.
Has thanked: 1 time
Been thanked: 19 times
Contact:

Re: cheat lua plugins

Post by Pugsy »

crazyc wrote: Sun Jan 27, 2019 4:36 pm The only thing that stands out is to use string.format in things like line 564 for languages which the number shouldn't be placed at the end for a proper translation.
Thanks, that makes them a lot easier to read.
crazyc wrote: Sun Jan 27, 2019 4:36 pm Not really my call, frankly your opinion would carry more weight here than mine IMO.
I doubt that + I wouldn't know where to start with it. Is it reasonable/easy/possible to have a LUA plugin outside the "plugin" menu?

Though making the "Cheat" menu a special case I guess will not fly with some mamedevs. If all the other menus like "Dip Switches" became LUA driven then I guess it would make total sense. Otherwise I can see the top level TAB Cheat menu disappearing - which would be a shame.
Pugsy

Servicing your cheating needs since 1985 8)

Grab the latest cheat collection:
MAME 0.264 XML cheat collection (3 APRIL 2024) from http://www.mamecheat.co.uk or direct from:-
https://mega.nz/file/SxsQUJoT#jBdz6GLm_ ... QzFGSMms2c (ZIP Archive 3.8 MB)
Post Reply