|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Fri Mar 03, 2017 10:46 pm Post subject: I2 CE Lua Script Template Generator |
|
|
I2 CE Lua Script Template Generator
No longer supported see
Lua Script Template Engine ("compiled templates")
A Lua file template system.
Version: 1.0.4
Forked Version of:
"Custom Lua Script Templates.lua":
Author: predprey
Basically a trimmed down version of "pluginI2CEAutoAssemblerScriptTemplateGenerator.lua" tailored for lua templates.
The Doc String.
Code: | --[====================================================================================================================[
I2 Cheat Engine Lua Script Template Generator
Version: 1.0.4
1.0.1:
First release.
1.0.2:
* I2 Template Changes
1.0.3:
* I2 Template Changes
1.0.4:
* I2 Template Changes
* Changed "getMainForm()" to "MainForm".
* Fixed "format" (to "string.format") in logger template.
TODO:
* Add function (at top) and timer (at bottom) to run table setup for table starter template.
Author: Matt - TheyCallMeTim13 - MattI2.com
Forked Version of:
"Custom Lua Script Templates.lua":
Author: predprey
Features:
- Allows for adding templates as tables or in a directory structure.
- Load templates function can be called multiple time to allow for standard and game specific templates.
- Template table structure sets the menu item structure created.
- Generic place holder key replacement though standard input forms.
- Gets the file version of the process's executable, for use in templates.
For the default templates see:
- CE Form >> Ctrl+M >> Ctrl+A >> Menu >> Templates >> I2 CEA Templates
To add templates use:
local TemplatesTable = {
...
}
I2CELuaScriptTemplates.loadTemplates(TemplatesTable)
To add templates from a directory:
I2CELuaScriptTemplates.loadTemplatesDirectory([[x:\SomeOddDirectory]])
Install / Setup Method 1:
- Put file in CE autorun folder, run Cheat engine.
Install / Setup Method 2:
- Put in CE lua folder (it isn't created by default).
And in a file in the CE autorun folder import and add tables.
Example:
local TemplatesTable = {
...
}
local I2CELSTG = require 'pluginI2CELuaScriptTemplateGenerator'
---- You could rename the file if you go this route.
I2CELSTG.loadTemplates(TemplatesTable)
Notes:
- Has a translation function that just returns the string back,
I want to look into translation setup for CE / Lua.
* See: 'TODO: Look into translation setup for CE.' / 'local function t(tanslationStr)'
- For some reason when using from an address list script the script will not get added to the form's text edit.
** Must use memory records to have added to address list for now (still figuring this out.)
But only happens with address list scripts.
Settings:
UserNameEnvKey : string - Environment variable key for user name.
i.e.: 'CE_USERNAME' or 'HEYBUDDYWHATSTHENAME'
UserName : string - Used for overriding the system's user name from environment ('USERNAME').
** See 'Environment Variable Keys' to override that way.
DateFormat : string - Lua date format string.
AddMainSeperator : boolean - Set to true to have a separator added to the menu before adding
template menu items.
PlaceHolderKey : string - The Place holder key used in templates for generic replacement prompts.
** See: 'Template Place Holders' for more info.
AutoLoad : boolean - Set to false to stop auto loading of templates.
TemplatesDirectory : string - The templates directory to use.
** *** Template files use a unique format, (my change to template files matched with json files for
settings) so this should be in a unique spot (IT CAN CLASH with other template generators
if in same folder).
Template Options: Table of settings for template generating.
Required Options:
DisplayString : string - The menu display string.
Bound Required Options: One or the other.
* TemplateString : string - The template string to use.
TemplateFile : string - The file path of the template.
*** Do not use multi extension files. (still figuring this one out)
i.e.: 'AOB_Injection.template.cea'
Instead try:
'AOB_Injection-template.cea '
Name : string - The name of the template.
*** Used in menu item creation, also in injection information and logging.
LineEnd : string - The line end string. (i.e.: '\n' or '\r\n')
Example Table:
Templates = {
Name = 'I2CELTemplates',
SectionDisplayString = 'I2 Lua Templates',
SectionName = 'miI2CELTemplatesSection',
{
Name = 'I2CEL_Header',
DisplayString = 'Header',
TemplateString = I2_TEMPLATE_HEADER,
},
'-----', ---- SEPERATOR
{
Name = 'I2CEL_Timer',
DisplayString = 'Timer',
TemplateString = I2_TEMPLATE_TIMER,
},
{
Name = 'I2CEL_BreakPoint',
DisplayString = 'Break Point',
TemplateString = I2_TEMPLATE_BREAK_POINT,
},
{
Name = 'I2CEL_Hotkey',
DisplayString = 'Hot-key',
TemplateString = I2_TEMPLATE_HOTKEY,
},
}
Template Keys:
- Keys to be used in templates and memory record strings.
format:
${TemplateKey}
ProcessName - The process name.
ProcessAddress - The process address.
Module - The address's module, if it is in a module.
ModuleAddress - The address's module address, if it is in a module.
ModuleSize - The address's module size, if it is in a module.
ModuleBitSize - The address's module bit size, if it is in a module.
i.e.: '(x32)' or '(x64)'
ModuleStr - Will be set to the word 'Module' if the address is in a module.
* Used with aob scan.
i.e.: 'aobScan${ModuleStr}(...'
ModuleDecl - Will be set to the module name with a comma in front, if the address is in a module.
* Used with aob scans, and memory allocation.
i.e.: 'aobScan${ModuleStr}(SomeUserSymbol${ModuleDecl}, bytes)'
i.e.: 'alloc(SomeUserSymbol, 0x400${ModuleDecl})'
Address - The address, will be in module with offset format, if the address is in a module.
* Pulled from disassembler view form selection.
AddressHex - The address in hex format, length is based on pointer size.
Date - The current date.
Author - The detected user name.
*** Set global 'CE_USERNAME', or environment variable 'CE_USERNAME', to override
the windows user name.
CEVersion - Cheat Engine's version.
PointerSize - The processes pointer size.
i.e.: x32 PointerSize is 4 and x64 PointerSize is 8.
PointerFtmStr - The processes pointer format string. (for lua use in templates)
i.e.: x32 PointerFtmStr is '%08X' and x64 PointerFtmStr is '%016X'.
PointerWordSize - The processes pointer declaration word.
i.e.: x32 PointerWordSize is 'dd' and x64 PointerWordSize is 'dq'.
PointerDefault - The processes pointer declaration with integer 0 value.
i.e.: x32 PointerWordSize is 'dd 0' and x64 PointerWordSize is 'dq 0'.
PointerDefaultFull - The processes pointer declaration with hex 0 value.
i.e.: x32 PointerDefaultFull is 'dd 00000000' and
x64 PointerDefaultFull is 'dq 0000000000000000'.
GameTitle - The game title. (See: 'Global Variables' for overriding process based value)
GameVersion - The game version. (See: 'Global Variables' for overriding determined value)
BaseAddressRegistry - Registry pulled form original code of the first line (uses lua matching).
BaseAddressOffset - Offset for registry pulled form original code of the first line (uses lua matching).
* Looks for most instructions followed by brackets with a registry and offset. Kinda works!
i.e.: mov eax,[rsi+10]
BaseAddressRegistry will be 'rsi'
BaseAddressOffset will be '10'
Template Place Holders:
- User will be prompted for replacement of key words, every thing after place holder key.
* Key words are striped of underscores and title cased before prompt.
i.e.:
PlaceHolder_Some_Value -> "Some Value"
PlaceHolder_the_ultimate_question -> "The Ultimate Question"
Key Start:
PlaceHolder_
Example:
local aTimer = nil
local aTimerInterval = ${PlaceHolder_Timer_Interval}
local aTimerTicks = 0
local aTimerTickMax = ${PlaceHolder_Timer_Tick_Max}
local function aTimer_tick(timer)
if aTimerTickMax > 0 and aTimerTicks >= aTimerTickMax then
timer.destroy()
end
aTimerTicks = aTimerTicks + 1
-- body
end
aTimer = createTimer(MainForm, false)
aTimer.Interval = aTimerInterval
aTimer.OnTimer = aTimer_tick
aTimer.Enabled = true
Templates:
Key Format:
${TemplateKey}
Example:
local autoAttachTimer = nil
local autoAttachTimerInterval = 100
local autoAttachTimerTicks = 0
local autoAttachTimerTickMax = 5000
local function autoAttachTimer_tick(timer)
if autoAttachTimerTickMax > 0 and autoAttachTimerTicks >= autoAttachTimerTickMax then
timer.destroy()
end
if getProcessIDFromProcessName('${ProcessName}') ~= nil then
timer.destroy()
openProcess('${ProcessName}')
end
autoAttachTimerTicks = autoAttachTimerTicks + 1
end
autoAttachTimer = createTimer(MainForm)
autoAttachTimer.Interval = autoAttachTimerInterval
autoAttachTimer.OnTimer = autoAttachTimer_tick
Template Files:
- Template files can be just a lua file or they can have a settings and template section
** *** Must be just a lua file, or have '[SETTINGS]' then '[TEMPLATE]' section in that order.
i.e.:
| Good | Good | Good | Bad |
|---------------|---------------|---------------|---------------|
| [SETTINGS] | [TEMPLATE] | ... | [TEMPLATE] |
| ... | ... | ... | ... |
| [TEMPLATE] | ... | ... | [SETTINGS] |
| ... | ... | ... | ... |
|---------------|---------------|---------------|---------------|
Lua Files:
- The standard lua format with templates keys, caption add menu section will be determinate by
file name and directory.
i.e.: 'some_template.lua' -> 'Some Template' - (Templates Menu)
i.e.: 'some_section\some_template.lua' -> 'Some Template' - 'Some Section' (miSomeSection)
Settings:
- Only allows basic setting (no nested settings at this point ?? json).
** *** Settings and template section keys must be the only thing on that line.
Template:
- The template to use (reads to end of file).
** *** Template and settings section keys must be the only thing on that line.
Example:
[SETTINGS]
DisplayString = 'Some Template'
[TEMPLATE]
print('I Have The Power!!')
Global Variables:
GAME_TITLE - The game title.
* If not set process name with out extension will be used.
** Manually set in table lua files, if needed.
GAME_VERSION - The game version.
* If not set value from 'getFileVersion' on the first module will be used.
** Manually set in table lua files, if needed.
Global Variables (Overridden by Settings):
[[ global - setting ]]
CE_USERNAME - UserName
I2CELSTG_AUTO_LOAD - AutoLoad
I2CELSTG_TEMPLATES_DIRECTORY - TemplatesDirectory
Global Variables (Overridden by Template Options):
[[ global - template option ]]
I2CELSTG_LINE_END - LineEnd
Environment Variable Keys: (Overridden by global variables)
CE_USERNAME - The name used for 'Author' template key.
]====================================================================================================================]--
|
_________________
Last edited by TheyCallMeTim13 on Tue Dec 21, 2021 7:34 pm; edited 12 times in total |
|
Back to top |
|
|
predprey Master Cheater Reputation: 24
Joined: 08 Oct 2015 Posts: 486
|
Posted: Sat Mar 04, 2017 8:52 am Post subject: |
|
|
you have some damn fine documentations, looks so much more professional. i'm feeling like a scriptkiddie here |
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Sun Dec 31, 2017 7:08 pm Post subject: |
|
|
Update 1.0.2:
- Mostly template changes.
_________________
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Tue Jan 09, 2018 2:26 am Post subject: |
|
|
Update:
Version: 1.0.3
_________________
|
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Wed Mar 14, 2018 9:32 pm Post subject: |
|
|
Updated:
Code: |
1.0.4:
* I2 Template Changes
* Changed "getMainForm()" to "MainForm".
* Fixed "format" (to "string.format") in logger template. |
_________________
|
|
Back to top |
|
|
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Fri Jul 23, 2021 9:17 pm Post subject: |
|
|
How can I print the last word written in Lua Script (if possible for each letter written) to Lua Engine (print(Lua Script.seltext)) with the help of a timer? |
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Sat Jul 24, 2021 6:55 am Post subject: |
|
|
ByTransient wrote: | How can I print the last word written in Lua Script (if possible for each letter written) to Lua Engine (print(Lua Script.seltext)) with the help of a timer? |
This module really isn't setup to do that, and in many cases you'd likely just get an "end". You could separate the lines of the script them seperate the words (using spaces as a delimiter). It would probably be better to just print the template name/description when generating a template. _________________
|
|
Back to top |
|
|
ByTransient Expert Cheater Reputation: 5
Joined: 05 Sep 2020 Posts: 240
|
Posted: Sat Jul 24, 2021 10:45 am Post subject: |
|
|
Sorry for the late reply.
I tried to create some useful code.
This code seems to be enough for a start.
I will now try to expand on this.
Code: | --aaa
l1=MainForm.frmAutoInject.Assemblescreen.Lines.Count
l2=tonumber(l1) - 1
aa=MainForm.frmAutoInject.Assemblescreen.Lines[l2]
print(l1.."\n"..aa)
function chars(str1)
local e1=str1
for i = 1, string.len(str1) do
e2=tonumber(string.len(str1))
--print("i: "..i)
if i==string.len(str1) then
e1 = string.sub(str1, e2, i)
--print("strc: "..e1)
end
end
return e1
end
function text1()
local char = chars(aa)
if char~="" then
print("Lines: "..l1.."\nLines Text: "..aa.."\nchar: "..char)
end
end
text1() |
PS: Your script above is great, but you have to let the user know, example; Before a timer is created, you must give the kill code (timer.Destroy(), timer=nil) to the user at the beginning of the script.
It's just an opinion, the decision is yours.
Also, it was very difficult to find the append function in your complex code, so I used the following code instead:
Code: | MainForm.frmAutoInject.Assemblescreen.Lines.Add("print('Hello Lua')") |
I guess your next step should be to translate this script into a CE Lua library.
There are many unknown syntaxes in CE and Lua.
And a lot of users, myself included, are looking for use cases for them.
I hope you continue to share and good ideas. |
|
Back to top |
|
|
TheyCallMeTim13 Wiki Contributor Reputation: 50
Joined: 24 Feb 2017 Posts: 976 Location: Pluto
|
Posted: Sat Jul 24, 2021 2:26 pm Post subject: |
|
|
ByTransient wrote: |
PS: Your script above is great, but you have to let the user know, example; Before a timer is created, you must give the kill code (timer.Destroy(), timer=nil) to the user at the beginning of the script.
... |
It's made to generates scripts, there are plenty of tutorials for learning. I don't like removing things I don't need every time I use the template. But you can edit the template or add a new one using the template directory.
ByTransient wrote: |
...
Also, it was very difficult to find the append function in your complex code, so I used the following code instead:
Code: | MainForm.frmAutoInject.Assemblescreen.Lines.Add("print('Hello Lua')") |
... |
There is no append function in the module. In this case I'd say edit the templates or make new ones, that's how it was setup to work.
ByTransient wrote: |
...
I guess your next step should be to translate this script into a CE Lua library.
... |
That's what it is, it's a lua module setup to run in the CE autorun folder.
ByTransient wrote: |
...
There are many unknown syntaxes in CE and Lua.
And a lot of users, myself included, are looking for use cases for them.
... |
Look through the "celua.txt" file in the CE directory, that's where the functions/classes CE adds are documented. And there are plenty of Lua tutorials out there. Any thing else you should just ask in the Lua scripting section. _________________
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|