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 


What am I doing wrong?

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

Joined: 01 Jun 2013
Posts: 4

PostPosted: Thu Jun 20, 2013 9:35 am    Post subject: What am I doing wrong? Reply with quote

New to LUA, getting a
Code:
Error:[string "errorOnLookupFailure(false)..."]:30: attempt to perform arithmetic on field 'Index' (a nil value)
error when trying to run the bulGetter function. What am I doing wrong?

Code:

errorOnLookupFailure(false)
bulDelta = 0
bullets = nil
bulletArray = nil
bulletData = nil

function bulGetter()
    activeBul = readInteger('[[[[["DATA.exe"+00FE5F34]+15c]+34]+10]+2d0]+a')
    if bulletArray == nil then
       registerSymbol(bulletArray)
       bulletArray = AOBScan('00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 02 00 00 00 02 00 00 00 03 00 00 00 03 00 00 00 05 00 00 00 04 00 00 00 06 00 00 00 05 00 00 00 09 00 00 00 06 00 00 00 0A 00 00 00 07 00 00 00 0B 00 00 00 08 00 00 00 0C 00 00 00 09 00 00 00')
    end
    if bulletData == nil then
       registerSymbol(bulletData)
       bulletData = AOBScan('00 00 00 00 0A 00 00 00 FF FF FF FF FF FF FF FF 00 00 C8 42 00 00 C8 42 9A 99 99 3E 00 00 20 41 00 00 80 3F 00 00 00 00 00 00 80 3F 00 00 80 3F 00 00 80 BF 00 00 C8 42 00 00 20 41 00 00 40 40 00 00 A0 40 00 00 80 3F 00 00 80 BF 00 00 80 3F')
    end
    if bullets == nil then
    bullets = {}
      for i=0,630 do
        local bulid = readInteger(getAddress(bulletArray)+(i*8))
        local bulnum = readInteger(getAddress(bulletArray)+(i*8)+4)
        table.insert(bullets,{bulletID = bulid,Index = bulnum})
      end
    end
    if activeBul ~= bulDelta then
      bulDelta = activeBul
      unregisterSymbol("bulIndex")
      for k,v in pairs(bullets) do
--        if v.bulletID == round(activeBul,-2) then
          registerSymbol("bulIndex",getAddress(bulletData)+v.Index*0x110,true)
--        end
      end
    end
end

function round(num, idp)
  local mult = 10^(idp or 0)
  return math.floor(num * mult + 0.5) / mult
end

form_show(MENU)
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25796
Location: The netherlands

PostPosted: Thu Jun 20, 2013 10:27 am    Post subject: Reply with quote

Not really sure.
your calls "registerSymbol(bulletArray)" and "registerSymbol(bulletData)" don't really do anything though, but shouldn't affect that for loop, unless you have defined bullets previously with anything that's doesn't contain Index

edit, ah ok I see it
getAddress(bulletArray) fails, because you're giving it as a stringlist object instead of a string. In 6.3 try getAddress(bulletArray.getString(0)) or getAddress(bulletArray[0])

because of that, getAddress returns 0, because you disabled error on lookup failure
and due to that readInteger fails because the address could not be read, so returns nil
That causes the Index to be nil, and nil*0x110 is just not allowed

_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
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