 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
orwasaker How do I cheat?
Reputation: 0
Joined: 09 Feb 2022 Posts: 4
|
Posted: Wed Feb 09, 2022 8:14 pm Post subject: How do I write this script so that I can use it twice? |
|
|
I have very little knowledge of how to write these scripts, I copied this one from the forums here and obviously changed the address and file name...but other than that I didn't change anything else
Here's the script:
tableWithValues = {}
for line in io.lines("my.txt") do
table.insert(tableWithValues,tonumber(line))
end
hk1 = createHotkey("writeValueFromList", VK_A, ...)
function writeValueFromList()
writeInteger('216CD224', tableWithValues[math.random(1, #tableWithValues)] )
end
My I tried copy pasting it underneath it, but also changing the hotkey, the file name, the address and changing "TableWithValues" to "TableWithValues2"
But what this did is assign both hotkeys to the 2nd address
Obviously I'm doing something wrong, can you tell me how to make copies of this script so that I can affect multiple addresses through multiple files?
_________________
none |
|
Back to top |
|
 |
ParkourPenguin I post too much
Reputation: 152
Joined: 06 Jul 2014 Posts: 4702
|
Posted: Wed Feb 09, 2022 10:29 pm Post subject: |
|
|
Pass an anonymous function to createHotkey:
Code: | createHotkey(function()
...
end, VK_WHATEVER, ...) |
Also, make sure you're destroying the previous hotkey.
Code: | if hk1 then hk1.destroy(); hk1 = nil end
hk1 = createHotkey(...) |
_________________
I don't know where I'm going, but I'll figure it out when I get there. |
|
Back to top |
|
 |
LeFiXER Grandmaster Cheater Supreme
Reputation: 20
Joined: 02 Sep 2011 Posts: 1069 Location: 0x90
|
Posted: Thu Feb 10, 2022 8:49 am Post subject: |
|
|
orwasaker wrote: |
When you put "..." between the end and the createhotkey function...do you mean that there's something I need to put there that you assume I already know?
I don't know where exactly to put any of this, can you just copy paste the code I wrote and insert what you wrote inside it so I know where it fits? |
That's right, you put the code of the function you want to execute upon pressing the hotkey.
Code: |
writeInteger('216CD224', tableWithValues[math.random(1, #tableWithValues)] )
|
|
|
Back to top |
|
 |
orwasaker How do I cheat?
Reputation: 0
Joined: 09 Feb 2022 Posts: 4
|
Posted: Thu Feb 10, 2022 8:52 am Post subject: |
|
|
LeFiXER wrote: | orwasaker wrote: |
When you put "..." between the end and the createhotkey function...do you mean that there's something I need to put there that you assume I already know?
I don't know where exactly to put any of this, can you just copy paste the code I wrote and insert what you wrote inside it so I know where it fits? |
That's right, you put the code of the function you want to execute upon pressing the hotkey.
Code: |
writeInteger('216CD224', tableWithValues[math.random(1, #tableWithValues)] )
|
|
Sorry I deleted the previous message because I thought you hadn't replied to it yet
Anyway I got what I want by simple changing the "WriteFromList" part...by just adding an S to it...that's it that's what made both codes now work as intended (and obviously still changing the address and the hotkey and naming it hk2)
_________________
none |
|
Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1522
|
Posted: Thu Feb 10, 2022 9:22 am Post subject: |
|
|
You should see the entire code you copied.
Examples may not be complete code.
Code: | tableWithValues = {}
for line in io.lines("my.txt") do --my.txt ? (ERROR!=No such file or directory) Path + my.txt ("C:\Users\UserName\Folder\YourList.txt")
table.insert(tableWithValues,tonumber(line))
end |
Except for a few things that are wrong, the shortcut functions should be:
Code: | function writeValueFromList1()
writeInteger('216CD224', tableWithValues[math.random(1, #tableWithValues)] ) --This is a very complex value assignment. I assume you know what this is doing!
end
function writeValueFromList2()
writeInteger('216CD224', tableWithValues[math.random(1, #tableWithValues)] )
end
--or
function allWriteValueFromList()
writeValueFromList1()
writeValueFromList2()
end
if hk1 then hk1.destroy(); hk1 = nil end
hk1 = createHotkey(writeValueFromList1, VK_A)
if hk2 then hk2.destroy(); hk2 = nil end
hk2 = createHotkey(writeValueFromList2, VK_B)
if hk3 then hk3.destroy(); hk3 = nil end
hk3 = createHotkey(allWriteValueFromList, VK_C) |
_________________
|
|
Back to top |
|
 |
orwasaker How do I cheat?
Reputation: 0
Joined: 09 Feb 2022 Posts: 4
|
Posted: Thu Feb 10, 2022 9:42 am Post subject: |
|
|
AylinCE wrote: | You should see the entire code you copied.
Examples may not be complete code |
It was the entire code, and it did the job I wanted it to do
AylinCE wrote: | This is a very complex value assignment. I assume you know what this is doing! |
I...do? is it really complex if all it does it pick a random value from the already created table of values, and assigns it to the address?
About the rest: thank you very much for that, though as I explained in the previous reply I already fixed it so that it does what I want it to do
Since I have you guys here, I have an additional question:
In this line: writeInteger('216CD1D4', tableWithValues[math.random(1, #tableWithValues)] )
How do I write it so that it gives the SAME random value to TWO addresses?
_________________
none |
|
Back to top |
|
 |
AylinCE Grandmaster Cheater Supreme
Reputation: 37
Joined: 16 Feb 2017 Posts: 1522
|
Posted: Thu Feb 10, 2022 10:02 am Post subject: |
|
|
Code: | function writeValueFromList()
local val=tableWithValues[math.random(1, #tableWithValues)]
writeInteger('216CD224', tonumber(val)) --address 1
writeInteger('216CD224', tonumber(val)) --address 2
end |
_________________
|
|
Back to top |
|
 |
orwasaker How do I cheat?
Reputation: 0
Joined: 09 Feb 2022 Posts: 4
|
|
Back to top |
|
 |
panraven Grandmaster Cheater
Reputation: 62
Joined: 01 Oct 2008 Posts: 958
|
Posted: Thu Feb 10, 2022 11:25 am Post subject: |
|
|
Code: |
--
hkStore = hkStore or {}
-- if dataFile is unique for each hotkey, it can be used as id like
--function hkRndWrite(dataFile, address, ...) -- ... is key combination
-- local id = dataFile
-- local hk , data= hkStore[id], {}
function hkRndWrite(id, dataFile, address, ...) -- ... is key combination
local hk, data = hkStore[id], {}
if hk and hk.Destroy then hkStore[id]=nil, hk.Destroy()end-- remove old hotkey object of same id
-- for test, replace: for l in io.lines(dataFile)do data[1+#data] = tonumber(l) end
for l in dataFile:gmatch'[%+%-]?%d+'do data[1+#data] = tonumber(l)end
if #data == 0 then
print('no data from '..dataFile)
return
else
hk = createHotkey(function(hkself)
--- for test, replace: writeInteger(address, data[math.random(1,#data)])
print(address, data[math.random(1,#data)])
end, ... ) --<-- setup key combination here
end
hkStore[id] = hk
return hk
end
-- define above once somewhere
--
--
-- test
--
-- reuse function
local a = hkRndWrite('test1','123 456 789', 'Addr1', VK_MBUTTON , VK_LCONTROL)
local b = hkRndWrite('test2','-123 -456 -7a89', 'Addr2', VK_MBUTTON , VK_LMENU)
createTimer(20000, function()for k,v in pairs(hkStore) do hkStore[k]=nil,v.Destroy() end print'gone' end)
|
_________________
- Retarded. |
|
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
|
|