Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Standalone trainer (.exe) parameters ?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Tsyal
How do I cheat?
Reputation: 0

Joined: 10 Nov 2019
Posts: 8

PostPosted: Fri Jan 31, 2020 10:30 am    Post subject: Standalone trainer (.exe) parameters ? Reply with quote

Can I start my trainer with a .bat like that :
"start mytrainer.exe param1 param2"
and have access of "param1" and "param2" in the lua script ?
Back to top
View user's profile Send private message
DanyDollaro
Master Cheater
Reputation: 3

Joined: 01 Aug 2019
Posts: 334

PostPosted: Fri Jan 31, 2020 10:56 am    Post subject: Reply with quote

Could help: https://en.wikibooks.org/wiki/Lua_Programming/command_line_parameter

Code:
-- Display the command line parameters
print(arg[0])    -- Name of the script
print(arg[1])    -- First parameter
print(arg[2])    -- Second parameter
Back to top
View user's profile Send private message
Tsyal
How do I cheat?
Reputation: 0

Joined: 10 Nov 2019
Posts: 8

PostPosted: Fri Jan 31, 2020 11:02 am    Post subject: Reply with quote

Thank you for the answer.

I already tried, but the arg variable does not seem to exist Sad
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Fri Jan 31, 2020 2:51 pm    Post subject: Reply with quote

This has no error handling etc. but this should allow you to pull local params:

Code:

local p = executeCodeLocal('GetCommandLineA');
local s = readStringLocal(p, 512);
print(s);

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
AylinCE
Grandmaster Cheater Supreme
Reputation: 37

Joined: 16 Feb 2017
Posts: 1532

PostPosted: Fri Jan 31, 2020 8:19 pm    Post subject: Reply with quote

Here are some examples.
You can use the following codes as 2 ".bat" files.
How to: Open notebook, paste the first code, "save file as", "closeTrainer.bat" or startTrainer.bat "ok.

or: https://forum.cheatengine.org/viewtopic.php?t=610493 (File name script.vbs or Close.bat )

Close: (.bat)
Code:
@echo off
taskkill /F  /IM notepad.exe


Start: (.bat)
Code:
@echo off
start  C:\Windows\notepad.exe


Here is a command for LuaScript:
Close:
Code:
os.execute("taskkill /F /IM notepad.exe")


Start:
Code:
os.execute("start  C:\\Windows\\notepad.exe")



Enjoy it!

EDIT:
If you are going to start 2 programs:
(.bat)
Code:
@echo off
start  C:\Windows\notepad.exe
start  C:\Windows\notepad.exe

_________________
Hi Hitler Different Trainer forms for you!
https://forum.cheatengine.org/viewtopic.php?t=619279
Enthusiastic people: Always one step ahead
Do not underestimate me Master: You were a beginner in the past
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Corroder
Grandmaster Cheater Supreme
Reputation: 75

Joined: 10 Apr 2015
Posts: 1668

PostPosted: Sun Feb 02, 2020 1:55 am    Post subject: Reply with quote

The arg argument is for Lua 5.0 only. Since Lua 5.1, the var arg expression ... is used instead.

Example:

Code:
function bar(...)
    for k, v in ipairs{...} do
        print(k, v)
    end
end

bar('cheat', 'engine')


or

Code:
-- double.lua
local input = ...   --- to get command line parameter
if input then
  local Double
  Double = function(input)
    return 2 * input
  end
  return print(Double(input))
end

--- to run:
lua.exe double.lua 15

_________________
Stealing Code From Stolen Code...
And Admit It.. Hmmm....Typically LOL


Last edited by Corroder on Sun Feb 02, 2020 5:32 am; edited 2 times in total
Back to top
View user's profile Send private message
Tsyal
How do I cheat?
Reputation: 0

Joined: 10 Nov 2019
Posts: 8

PostPosted: Sun Feb 02, 2020 5:01 am    Post subject: Reply with quote

atom0s wrote:
This has no error handling etc. but this should allow you to pull local params:

Code:

local p = executeCodeLocal('GetCommandLineA');
local s = readStringLocal(p, 512);
print(s);


I try your code with this .bat :
Code:

start CETestParams_2.EXE test


and here is the output :
C:\Users\.....\AppData\Local\Temp\cetrainers\CETB318.tmp\extracted\CETestParams_2.EXE "C:\Users\.....\AppData\Local\Temp\cetrainers\CETB318.tmp\extracted\CET_TRAINER.CETRAINER" "-ORIGIN:C:\Users\.....\Desktop\TestParams\"

It seems to be going through a temporary folder and params are lost
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Feb 02, 2020 12:06 pm    Post subject: Reply with quote

Looks like the trainer generator is ignoring params or restarting itself and dropping them. You could make a issue/request on the GitHub for CE and request that feature be added.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites