 |
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
etioplmld Advanced Cheater
Reputation: 0
Joined: 09 Feb 2021 Posts: 76
|
Posted: Wed May 10, 2023 7:24 am Post subject: Can chatgpt generate ce lua code? |
|
|
Has anyone tried?
|
|
Back to top |
|
 |
cooleko Grandmaster Cheater
Reputation: 11
Joined: 04 May 2016 Posts: 717
|
Posted: Wed May 10, 2023 9:48 am Post subject: |
|
|
Chat GPT has this to say:
Quote: | >>> Do you know LUA?
Yes, I'm familiar with Lua. ...
>>> Do you know the cheat engine API for lua?
Yes, I'm familiar with the Cheat Engine API for Lua. ...
>>> Can you assist me with shell code for reading a float value at a first memory location, and if the value is less than a first threshold, writing the value with a stored float variable?
Certainly! Here's an example of Lua code using the Cheat Engine API ...
Code: | -- Define the memory address to read from and the threshold value
local addressToRead = 0x12345678 -- Replace with your desired memory address
local threshold = 10.0 -- Replace with your desired threshold value
-- Define the stored float variable to write if the condition is met
local storedFloat = 20.0 -- Replace with your desired stored float value
-- Read the float value from the memory address
local currentValue = readFloat(addressToRead)
-- Compare the current value with the threshold
if currentValue < threshold then
-- Write the stored float value to the memory address
writeFloat(addressToRead, storedFloat)
end |
>>> Can you place that on a timer than runs every 250ms?
Certainly! Here's an updated version of the Lua code ...
Code: | -- Define the memory address to read from and the threshold value
local addressToRead = 0x12345678 -- Replace with your desired memory address
local threshold = 10.0 -- Replace with your desired threshold value
-- Define the stored float variable to write if the condition is met
local storedFloat = 20.0 -- Replace with your desired stored float value
-- Function to be executed on each timer tick
local function checkAndUpdateMemory()
-- Read the float value from the memory address
local currentValue = readFloat(addressToRead)
-- Compare the current value with the threshold
if currentValue < threshold then
-- Write the stored float value to the memory address
writeFloat(addressToRead, storedFloat)
end
end
-- Create a timer that executes the function every 250 milliseconds
local timer = createTimer(nil, true)
timer.Interval = 250
timer.OnTimer = checkAndUpdateMemory
timer.Enabled = true |
>>> Can you replace the addresstoread with a three level pointer?
Certainly! Here's an updated version of the Lua code ...
Code: | -- Define the base address and the pointer offsets
local baseAddress = 0x12345678 -- Replace with the base address
local pointerOffsets = {0x100, 0x200, 0x300} -- Replace with your desired pointer offsets
-- Define the threshold value
local threshold = 10.0 -- Replace with your desired threshold value
-- Define the stored float variable to write if the condition is met
local storedFloat = 20.0 -- Replace with your desired stored float value
-- Function to resolve the multi-level pointer
local function resolvePointer()
-- Get the final address by following the pointer chain
local finalAddress = baseAddress
for i, offset in ipairs(pointerOffsets) do
finalAddress = readPointer(finalAddress + offset)
if finalAddress == nil then
return nil -- Return nil if any of the pointers is invalid
end
end
return finalAddress
end
-- Function to be executed on each timer tick
local function checkAndUpdateMemory()
-- Resolve the final address using the pointer chain
local addressToRead = resolvePointer()
if addressToRead ~= nil then
-- Read the float value from the memory address
local currentValue = readFloat(addressToRead)
-- Compare the current value with the threshold
if currentValue < threshold then
-- Write the stored float value to the memory address
writeFloat(addressToRead, storedFloat)
end
else
print("Invalid pointer chain!") -- Handle invalid pointer chain
end
end
-- Create a timer that executes the function every 250 milliseconds
local timer = createTimer(nil, true)
timer.Interval = 250
timer.OnTimer = checkAndUpdateMemory
timer.Enabled = true
|
|
|
|
Back to top |
|
 |
atom0s Moderator
Reputation: 204
Joined: 25 Jan 2006 Posts: 8578 Location: 127.0.0.1
|
Posted: Wed May 10, 2023 1:15 pm Post subject: |
|
|
While you can get ChatGPT to produce valid code some of the time on generalized questions/basic stuff, you are going to notice it struggles on more in-depth examples. ChatGPT isn't trained on specific API implementations or modifications to programming/scripting languages like Lua and how CE has custom-implemented things into it. Because of that, it will often mix other projects' Lua modifications into code it generates and will assume its valid in all situations that make use of Lua.
For example, if you ask it about how to handle certain events/callbacks in CE, you may land up with it giving you examples of Lua code that are from World of Warcraft addons and how those handle event callbacks. Or if you ask it how to produce a certain style of image, it may spit out how to make use of a third-party library that requires additional things that are not built into CE's Lua implementation that it assumes is valid / stock Lua code.
Note that the newer ChatGPT 4 is much better in this kind of situation as you can use plugins to allow it to learn and pull from specific information sources, search the web, etc. so it can learn from more direct bits of info, but it costs money.
_________________
- Retired. |
|
Back to top |
|
 |
++METHOS I post too much
Reputation: 92
Joined: 29 Oct 2010 Posts: 4197
|
Posted: Wed May 10, 2023 1:50 pm Post subject: |
|
|
atom0s wrote: | Note that the newer ChatGPT 4 is much better in this kind of situation as you can use plugins to allow it to learn and pull from specific information sources, search the web, etc. so it can learn from more direct bits of info, but it costs money. | -Yes. I have not tried GPT4 yet. When I tried using ChatGPT3 to do some coding in MQL5, it really struggled to produce anything viable. However, my thought was that if it could gain access to the web and scrape MQL5.com's database of user-made scripts, for example, then that could potentially be very useful.
Similarly, if it could scrape a database of CE tables and lua snippets etc.. while possessing the necessary understanding to work with that data, then that could potentially be very interesting.
|
|
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
|
|