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 


I need to hire a script developer

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

Joined: 08 Nov 2010
Posts: 5

PostPosted: Sat Sep 09, 2017 9:37 pm    Post subject: I need to hire a script developer This post has 1 review(s) Reply with quote

Hi. I am mapping item IDs in a game. I have a memory address in the memory viewer and I set the value to like 600 then I alt-tab over to the game and check what item is in my hand. I log it, then I go back to Cheat Engine and change value to 601 then repeat. It's tedious. I tried to use both Macro Express and AutoHotKey to activate the CE window, hit enter then then the next ID but as soon as CE gets focus, the macro dies.

Soooo, my next option is a Lua script I imagine. Can someone fluent in Lua make something that either increments the value by 1 every X seconds or increments by 1 when a certain keystroke is hit? Ideally the former as the less interaction the better as far as efficiency. I'd just need to be able to configure the delay, the starting value and the memory address to work on.

If someone could do that, and has PayPal, let give me a quote.
Back to top
View user's profile Send private message
FreeER
Master Cheater
Reputation: 12

Joined: 09 Aug 2013
Posts: 344

PostPosted: Sun Sep 10, 2017 7:18 am    Post subject: Reply with quote

something like this should work
Code:
{$lua}
[ENABLE]
-- start of configuration
  local interval = 1000 -- milliseconds
  local address = '[[game.exe+baseoffset]+offset1]+offset2' -- supports pointer notation
  local valueType = vtDword -- vtByte,vtWord,vtDword,   vtQword,vtSingle,vtDouble
  local signed = false -- vtQword,vtSingle,vtDouble always signed, qword errors on negative if false
  local incrementBy = 1
  local maxValue = math.huge -- infinity
  local minValue = -math.huge
  local interaction_type = 'timer' -- 'timer' or 'hotkey'
  local hotkeys = {VK_1} -- table of keys for hotkey if interaction_type is 'hotkey'
-- end of configuration

function incrementValue()
  if valueType == vtByte then
    local value = readBytes(address,1)
    if signed and value > 0x7F then value = value - 0xFF - 1 end
    value = value+incrementBy
    if value < maxValue and value > minValue then writeBytes(address,value) end
  elseif valueType == vtWord then
    -- pre 6.7 did not have read/write SmallInteger
    readSmallInteger = readSmallInteger or function (address,signed)
      local bytes = readBytes(address,2,true)
      local value = byteTableToWord(bytes)
      if signed and value > 0x7FFF then value = value - 0xFFFF -1 end
      return value
    end
    writeSmallInteger = writeSmallInteger or function (address,value) writeBytes(address, wordToByteTable(value)) end

    local value = readSmallInteger(address, signed)
    value = value+incrementBy
    if value < maxValue and value > minValue then writeSmallInteger(address,value) end
  elseif valueType == vtDword then
    local value = readInteger(address, signed)
    value = value+incrementBy
    if value < maxValue and value > minValue then writeInteger(address,value) end
  elseif valueType == vtQword then
    local value = readQword(address) -- always reads as signed...
    if value < 0 and not signed then error("large unsigned qwords are not supported") end
    value = value+incrementBy -- can overflow to negative
    if value < 0 and not signed then error("large unsigned qwords are not supported") end
    if value < maxValue and value > minValue then writeQword(address,value) end
  elseif valueType == vtSingle then -- always signed by definition/implementation
    local value = readFloat(address)
    value = value+incrementBy
    if value < maxValue and value > minValue then writeFloat(address,value) end
  elseif valueType == vtDouble then -- always signed by definition/implementation
    local value = readDouble(address)
    value = value+incrementBy
    if value < maxValue and value > minValue then writeDouble(address,value) end
  else error("Invalid type: " .. tostring(valueType))
  end
end

if type(interaction_type) ~= 'string' then error('interaction_type must be a string!') end

if syntaxcheck then return end

if interaction_type:lower() == 'timer' then
  incrementingObject = createTimer()
  incrementingObject.interval = interval
  incrementingObject.OnTimer = incrementValue
elseif interaction_type:lower() == 'hotkey' then
  incrementingObject = createHotkey(incrementValue, hotkeys)
else error('unknown interaction_type ' .. interaction_type)
end
[DISABLE]
if syntaxcheck then return end
incrementingObject.destroy()


paypal.me/FreeER (edit: I did get payed)


Last edited by FreeER on Wed Sep 13, 2017 6:08 pm; edited 1 time in total
Back to top
View user's profile Send private message
Strahan
How do I cheat?
Reputation: 1

Joined: 08 Nov 2010
Posts: 5

PostPosted: Sun Sep 10, 2017 5:24 pm    Post subject: Reply with quote

Wow, thanks.

This is what I'm working with:

EDIT: Ack, it won't let me post URLs. I used the attachment feature instead.

The highlighted memory location is what I am incrementing. So for address do I just do local address = '88D16D74' or do I need to put the game executable name and all that stuff you have? I assume I also do local valueType = vtByte but how do I indicate 2 bytes?

Sorry, I know nothing about Lua or CE scripting, I'm pretty noob here lol.



cheat_engine.jpg
 Description:
 Filesize:  184.89 KB
 Viewed:  2982 Time(s)

cheat_engine.jpg


Back to top
View user's profile Send private message
FreeER
Master Cheater
Reputation: 12

Joined: 09 Aug 2013
Posts: 344

PostPosted: Sun Sep 10, 2017 5:38 pm    Post subject: Reply with quote

yeah
Code:
local address = '88D16D74'
will work Smile
For 2 bytes you'd use vtWord, based on the Microsoft programming data type "WORD" used for the size of a CPU register back in the 16 bit days.
Back to top
View user's profile Send private message
cooleko
Grandmaster Cheater
Reputation: 10

Joined: 04 May 2016
Posts: 507

PostPosted: Mon Sep 11, 2017 12:45 pm    Post subject: Reply with quote

I wrote a program in c# that performed something similar for another game, if these solutions dont work, just send me a pm.

My c# script writes a memory address and takes a screenshot of a specific icon on the game to correlate IDs with items.
Back to top
View user's profile Send private message
Strahan
How do I cheat?
Reputation: 1

Joined: 08 Nov 2010
Posts: 5

PostPosted: Wed Sep 13, 2017 5:30 pm    Post subject: Reply with quote

Thanks, the script worked great.

Could I trouble you for one more? This one should be (I imagine) relatively simple. When I change worlds, all the addresses change and I have to remap it. The game has a 7 slot hotbar. I track down the memory location for slot 1, then each subsequent slot is +4. So right now for instance I have:

Slot 1: 88B16936, Byte
Slot 2: 88B1693A, Byte
Slot 3: 88B1693E, Byte
Slot 4: 88B16942, Byte

..so on and so forth. Then the item ID for each slot is slot memory address -2 so slot 1's ID is 88B16934 and is 2 bytes.

Would it be possible to have a script wherein I tell it the first slot's memory address then it automatically adds the rest of the slots and the slot ID locations to the table of addresses? That'd save sooo much time.

Thanks!
Back to top
View user's profile Send private message
FreeER
Master Cheater
Reputation: 12

Joined: 09 Aug 2013
Posts: 344

PostPosted: Wed Sep 13, 2017 6:05 pm    Post subject: Reply with quote

You shouldn't actually need a script for that Smile If you "nest" a memory record under another (drag and drop on top) then you can use +4 as the address to have it act much like a pointer and use the parent's address+4

eg.

(copy and paste in CE address list) https://pastebin.com/v4gimdkU

short example (xml is super verbose...)
Code:
<?xml version="1.0" encoding="utf-8"?>
<CheatTable>
  <CheatEntries>
    <CheatEntry>
      <ID>0</ID>
      <Description>"Slot Base"</Description>
      <VariableType>Byte</VariableType>
      <Address>88B16936</Address>
      <CheatEntries>
        <CheatEntry>
          <ID>15</ID>
          <Description>"Slot 1"</Description>
          <VariableType>Byte</VariableType>
          <Address>+0</Address>
          <CheatEntries>
            <CheatEntry>
              <ID>16</ID>
              <Description>"id"</Description>
              <VariableType>2 Bytes</VariableType>
              <Address>-2</Address>
            </CheatEntry>
          </CheatEntries>
        </CheatEntry>
      </CheatEntries>
    </CheatEntry>
  </CheatEntries>
</CheatTable>


So then you just need to set the address of the "Slot Base" to the address of the first slot. Unfortunately I don't know any way to set that up without the base showing the type and value so you end up duplicating Slot 1 a little using that method.

Back to top
View user's profile Send private message
Strahan
How do I cheat?
Reputation: 1

Joined: 08 Nov 2010
Posts: 5

PostPosted: Thu Sep 14, 2017 1:20 pm    Post subject: Reply with quote

Ahh cool. I need to learn more about how to work this rather than grope along blindly, wasn't aware I could do that.

I pasted your XML in, then double clicked the slot base and set it to the memory address that was valid at the time - 88D201E2. All the child entry values though stayed as question marks. Is there something I have to do to tell it to "refresh" or activate or whatever?


Last edited by Strahan on Thu Sep 14, 2017 1:24 pm; edited 2 times in total
Back to top
View user's profile Send private message
FreeER
Master Cheater
Reputation: 12

Joined: 09 Aug 2013
Posts: 344

PostPosted: Thu Sep 14, 2017 1:23 pm    Post subject: Reply with quote

hm, shouldn't be. Setting the parent should cause the address for all the children to update and as long as the resulting address is valid the value should show.
Back to top
View user's profile Send private message
Strahan
How do I cheat?
Reputation: 1

Joined: 08 Nov 2010
Posts: 5

PostPosted: Thu Sep 14, 2017 1:24 pm    Post subject: Reply with quote

I realized when I saw your screenshot you were on a version .6 higher than I. I upgraded and bam, now it works Smile Thanks.
Back to top
View user's profile Send private message
FreeER
Master Cheater
Reputation: 12

Joined: 09 Aug 2013
Posts: 344

PostPosted: Thu Sep 14, 2017 1:28 pm    Post subject: Reply with quote

ah! Yeah, that'd make a difference lol
Back to top
View user's profile Send private message
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