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 script with function cannot be assigned to table?

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

Joined: 10 Oct 2016
Posts: 10

PostPosted: Fri Oct 28, 2016 9:56 am    Post subject: Lua script with function cannot be assigned to table? Reply with quote

Hi,

I've made a Lua script for my cheat table (h3hota). It works fine on Lua engine. However, when I tried to add it to the cheat table, it generates an error: Error in line 3 (function setResources()): This instruction cannot be compiled. I found two ways to solve this problem:

  1. Adding Lua script manually by editing cheat engine file .CT (symbols like < or > must be changed to &lt; or &gt;)
  2. Seperate my function using Table >> Show Cheat Table Lua Script (Ctrl + Alt + L) (it shows pop up!)


Here's the full code:
Code:
[ENABLE]
{lua}
function setResources()
   local pointer = readPointer("0069CCFC")
   for i = 6, 0, -1 do
      local addr = pointer + 0x9c + 4*i
      if i==6 then
         if readPointer(addr) &lt; 5000000 then
            writeInteger(addr, 5000000)
         else
            break
         end
      else
         if readPointer(addr) &lt;5000 then
            writeInteger(addr, 5000)
         end
      end
   end
end

GameTimer=createTimer(nil)
GameTimer.Interval=5000
GameTimer.OnTimer = setResources
GameTimer.Enabled = true

[DISABLE]
GameTimer.destroy()
{asm}
{

}

Still, I want to ask if this was a bug with Cheat Engine? Because I found no way to automatically add my script to the table (with enable/disable function) without using Auto Assemble >> File >> Assign to current cheat table.
Back to top
View user's profile Send private message
Zanzer
I post too much
Reputation: 126

Joined: 09 Jun 2013
Posts: 3278

PostPosted: Fri Oct 28, 2016 10:25 am    Post subject: Reply with quote

{$lua}
Code:
[ENABLE]
{$lua}
function setResources()
   local pointer = readPointer("0069CCFC")
   for i = 6, 0, -1 do
      local addr = pointer + 0x9c + 4*i
      if i==6 then
         if readPointer(addr) < 5000000 then
            writeInteger(addr, 5000000)
         else
            break
         end
      else
         if readPointer(addr) < 5000 then
            writeInteger(addr, 5000)
         end
      end
   end
end

GameTimer=createTimer(nil)
GameTimer.Interval=5000
GameTimer.OnTimer = setResources
GameTimer.Enabled = true

[DISABLE]
GameTimer.destroy()
{$asm}
{

}
Back to top
View user's profile Send private message
mgr.inz.Player
I post too much
Reputation: 222

Joined: 07 Nov 2008
Posts: 4438
Location: W kraju nad Wisla. UTC+01:00

PostPosted: Fri Oct 28, 2016 3:05 pm    Post subject: Reply with quote

Yes, missing $ symbol

you should use:
{$Lua} and {$Asm}


Not those
{Lua} and {Asm}

_________________
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