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 


lua error

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
thenewcomer
Newbie cheater
Reputation: 0

Joined: 09 Mar 2013
Posts: 22
Location: Behind you

PostPosted: Sat Oct 26, 2013 8:08 pm    Post subject: lua error Reply with quote

ive been messing around some and found
Code:
function DEC_HEX(IN)
    local B,K,OUT,I,D=16,"0123456789ABCDEF","",0
   if IN<1 then
      OUT=0
      return OUT
   end
    while IN>0 do
        I=I+1
        IN,D=math.floor(IN/B),math.mod(IN,B)+1
        OUT=string.sub(K,D,D)..OUT
    end
    return OUT
end

function Aobswap(search, change)
   aobs = AOBScan(search)
   if(aobs ~= nil) then
      j = stringlist_getCount(aobs)
      --print("Found:",j);
      for i = 1, j do
         --print(stringlist_getString(aobs,i-1));
            --66 ?? ?? d1 a1 68 ?? ?? d0 d0
         address=stringlist_getString(aobs,i-1)
                for i = 1, string.len(change), 3 do
               z = string.sub(change, i, i+2)
                    x, y = string.find(z, "%?+")
                    if (x == nil) then
                  script=[[
                  ]]..address.."+"..(DEC_HEX((i-1)/3))..[[:
                  db ]]..z..[[
                  ]]
                  autoAssemble(script)
                  --print(z)
                        --print(address.."+"..(DEC_HEX((i-1)/3)))
                    end
                end
      end
      object_destroy(aobs);
      aobs=nil
   end
end
somewhere on the site and its very helpful. the problem im having is i want to make it portable, rather than needing it in the autorun folder. when i try to put it into a CT using the <LuaScript> it throws an error of "name starts with invalid character" and fails to load the cheat table. and if i remove the first function, it loads the table but i receive another error "attempt to call global 'DEC_HEX' (a nil value)" when trying to actually use it.

i know this would seem painfully obvious to most of you as to why it wont work, but im clueless. any help or information would be much appreciated


edit: ill put the whole table here in case you need it
Code:
<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="16">
<LuaScript>
function DEC_HEX(IN)
    local B,K,OUT,I,D=16,"0123456789ABCDEF","",0
     if IN<1 then
    OUT=0
    return OUT
  end
  while IN>0 do
    I=I+1
    IN,D=math.floor(IN/B),math.mod(IN,B)+1
    OUT=string.sub(K,D,D)..OUT
    end
    return OUT
end

function Aobswap(search, change)
     aobs = AOBScan(search, "+W")
     if(aobs == nil) then AobSwapCheck=false else
     j = stringlist_getCount(aobs)
     for i = 1, j do
     address=stringlist_getString(aobs,i-1)
     for i = 1, string.len(change), 3 do
     z = string.sub(change, i, i+2)
     x, y = string.find(z, "%?+")
      if (x == nil) then
     script=[[
     ]]..address.."+"..(DEC_HEX((i-1)/3))..[[:
     db ]]..z..[[
     ]]
     autoAssemble(script)
     end
     end
     end
     object_destroy(aobs);
     aobs=nil
     AobSwapCheck=true
    end
end
</LuaScript>
  <CheatEntries>
        <CheatEntry>
          <ID>13</ID>
          <Description>"Hacks"</Description>
          <Color>A00000</Color>
          <VariableType>Auto Assembler Script</VariableType>
          <LuaScript>
aobresult=aobscan("8B 54 87 0C 89 95 ?? ?? FF FF 8B 85 ?? ?? FF FF 89 85 A0 F9 FF FF 8B 85 A0 F9 FF FF 83 40 44 FF")
if (aobresult~=nil) then
   label(_typeOne)
   registersymbol(_typeOne)
end
aobresult=aobscan("8B 54 87 0C 89 95 ?? ?? FF FF 8B 85 ?? ?? FF FF 89 85 A0 F9 FF FF 8B 85 A0 F9 FF FF FF 48 44")
if (aobresult~=nil) then
   label(_typeTwo)
   registersymbol(_typeTwo)
end
</LuaScript>
          <AssemblerScript>[ENABLE]

LuaCall(Aobswap("8B 54 87 0C 89 95 ?? ?? FF FF 8B 85 ?? ?? FF FF 89 85 A0 F9 FF FF 8B 85 A0 F9 FF FF 83 40 44 FF","8B 54 87 0C 89 95 ?? ?? FF FF 8B 85 ?? ?? FF FF 89 85 A0 F9 FF FF 8B 85 A0 F9 FF FF 90 90 90 90"))
LuaCall(Aobswap("8B 54 87 0C 89 95 ?? ?? FF FF 8B 85 ?? ?? FF FF 89 85 A0 F9 FF FF 8B 85 A0 F9 FF FF FF 48 44","8B 54 87 0C 89 95 ?? ?? FF FF 8B 85 ?? ?? FF FF 89 85 A0 F9 FF FF 8B 85 A0 F9 FF FF 90 90 90"))

[DISABLE]
_typeOne+1C:
db 83 40 44 FF
_typeTwo+1C:
db FF 48 44

unregistersymbol(_typeOne)
unregistersymbol(_typeTwo)
</AssemblerScript>
        </CheatEntry>
  </CheatEntries>
  <Comments>Info about this table:
</Comments>
</CheatTable>


double edit: i feel like it might have something to do with the variable type, but i have no idea how to fix it

_________________
-TNC
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Sat Oct 26, 2013 9:15 pm    Post subject: This post has 1 review(s) Reply with quote

Make sure you input the script using the table->lua script. Do not edit the .ct with a texteditor since you will miss some special character conversions
_________________
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
thenewcomer
Newbie cheater
Reputation: 0

Joined: 09 Mar 2013
Posts: 22
Location: Behind you

PostPosted: Sun Oct 27, 2013 8:34 am    Post subject: wow Reply with quote

thanks darkbyte, i didnt realize there was a character conversion and was editing the ct like you said. i feel quite stupid now that its working Razz
_________________
-TNC
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