Please proofread my script

Want Cheat Engine to do something specific and no idea how to do that, ask here. (From simple scripts to full trainers and extensions)
Post Reply
User avatar
Las0mbra
Novice Cheater
Novice Cheater
Posts: 21
Joined: Fri Mar 17, 2017 10:53 am
Reputation: 3

Please proofread my script

Post by Las0mbra » Thu Nov 16, 2017 3:08 pm

The script appears to work as it should but I have just a bit of experience with lua and almost no experience using it in CE.

So if anyone has the time to look it over I'd appreciate it.

The "bpointer" was found using a AA script beforehand.

Code: Select all

[ENABLE]
{$lua}
  errorOnLookupFailure(false)

  isAlly = "[bpointer]+30"
  maxTroops = "[bpointer]+38"
  curTroops = "[bpointer]+3C"


  function GodMode()

    unitAlly = readBytes(isAlly, 1)
    unitMaxTroops = readInteger(maxTroops)
    unitCurTroops = readInteger(curTroops)

    if (unitAlly and unitMaxTroops and unitCurTroops) then
      if (unitAlly == 1)
        then writeInteger(curTroops, unitMaxTroops)
      end
    end
  end


  RepeatTimer = createTimer(nil,true)
  RepeatTimer.Interval = 250
  RepeatTimer.onTimer = GodMode

{$asm}

[DISABLE]
{$lua}

  RepeatTimer.enabled = false

{$asm}

User avatar
seikur0
Expert Cheater
Expert Cheater
Posts: 155
Joined: Sat Aug 26, 2017 10:48 am
Reputation: 111

Re: Please proofread my script

Post by seikur0 » Thu Nov 16, 2017 5:03 pm

Seems good, though you could probably do it with autoassembler instead of lua in a much easier way by finding some code that's accessing the current troops and injecting there.

User avatar
Las0mbra
Novice Cheater
Novice Cheater
Posts: 21
Joined: Fri Mar 17, 2017 10:53 am
Reputation: 3

Re: Please proofread my script

Post by Las0mbra » Thu Nov 16, 2017 8:52 pm

seikur0 wrote:
Thu Nov 16, 2017 5:03 pm
Seems good,
Thanks for looking it over. I'm glad there is nothing major wrong with it.
seikur0 wrote:
Thu Nov 16, 2017 5:03 pm
though you could probably do it with autoassembler instead of lua in a much easier way by finding some code that's accessing the current troops and injecting there.
Yeah probably. At the time lua seemed easier to figure out.

User avatar
seikur0
Expert Cheater
Expert Cheater
Posts: 155
Joined: Sat Aug 26, 2017 10:48 am
Reputation: 111

Re: Please proofread my script

Post by seikur0 » Thu Nov 16, 2017 9:16 pm

One thing that came to mind just now: You should delete the timer object in your disable section with RepeatTimer.destroy().

User avatar
Las0mbra
Novice Cheater
Novice Cheater
Posts: 21
Joined: Fri Mar 17, 2017 10:53 am
Reputation: 3

Re: Please proofread my script

Post by Las0mbra » Thu Nov 16, 2017 10:16 pm

Replaced the RepeatTimer.enabled = false with RepeatTimer.destroy(). Thanks.

Post Reply

Who is online

Users browsing this forum: No registered users