Page 1 of 1

Please proofread my script

Posted: Thu Nov 16, 2017 3:08 pm
by Las0mbra
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}

Re: Please proofread my script

Posted: Thu Nov 16, 2017 5:03 pm
by seikur0
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.

Re: Please proofread my script

Posted: Thu Nov 16, 2017 8:52 pm
by Las0mbra
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.

Re: Please proofread my script

Posted: Thu Nov 16, 2017 9:16 pm
by seikur0
One thing that came to mind just now: You should delete the timer object in your disable section with RepeatTimer.destroy().

Re: Please proofread my script

Posted: Thu Nov 16, 2017 10:16 pm
by Las0mbra
Replaced the RepeatTimer.enabled = false with RepeatTimer.destroy(). Thanks.