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 


[Solved] Problem with "less than" operator on CETr

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

Joined: 10 May 2013
Posts: 3

PostPosted: Fri May 10, 2013 2:29 am    Post subject: [Solved] Problem with "less than" operator on CETr Reply with quote

hi everyone, its my first time using lua on CE (and using Lua at all) and wanted to ask: why is this code from my CETrainer file failing at line 7 position 8?
Code:

<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="14">
  <Forms/>
  <UserdefinedSymbols/>
  <LuaScript>
key=4
if key<5 then
  showMessage("yay")
else
  showMessage("nay")
end
</LuaScript>
</CheatTable>


it works on the Lua Engine, and changing the logical evaluator from less than to greater than works as expected, is there some special function that do logical comparisions?

also, I cant leave space between the logical operator and the values to compare like on the Lua examples from lua dot org using less than ("whitespace is not allowed here"), but I can with greater than, and that doesn't happen with Lua Engine either.


Last edited by Casatodo Total on Fri May 10, 2013 4:14 am; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Fri May 10, 2013 2:38 am    Post subject: Reply with quote

I think you used a text editor to edit the .xml file instead of using cheat engine

In xml, you must change < with &lt; and some other things
Code:

<?xml version="1.0" encoding="utf-8"?>
<CheatTable CheatEngineTableVersion="14">
  <CheatEntries/>
  <UserdefinedSymbols/>
  <LuaScript>key=4
if key&lt;5 then
  showMessage("yay")
else
  showMessage("nay")
end
</LuaScript>
</CheatTable>

_________________
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
Casatodo Total
How do I cheat?
Reputation: 0

Joined: 10 May 2013
Posts: 3

PostPosted: Fri May 10, 2013 3:19 am    Post subject: Reply with quote

yes, I use a text editor to editing the CETrainer, I cant use cheat engine to edit more than the form GUI and its initial properties (that looks nothing friendly on text) and select which values from the game the trainer must get (in fact, I must raise an error on the trainer like bringing an nonexistant form to get the lua engine and test code there)

then this error is because its evaluating if the less than came from xml instead of from Lua? will I need to do that if I do a require(luafile) on the xml file calling a lua file as explained on the CE wiki?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 458

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

PostPosted: Fri May 10, 2013 3:51 am    Post subject: Reply with quote

table->show cheat engine lua script will show the trainer script
If you have to, just paste the script in there when done editing it with another editor

_________________
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
Casatodo Total
How do I cheat?
Reputation: 0

Joined: 10 May 2013
Posts: 3

PostPosted: Fri May 10, 2013 4:12 am    Post subject: Reply with quote

Dark Byte wrote:
table->show cheat engine lua script will show the trainer script

it shows nothing, I think it has to do with me having WinXP or something, will test with other WinOS to see it

and I had to use dofile("file.lua") cause require("file") only works once, for testing purposes, it reloads the trainer but dont execute the scripts again but "less than" works Razz

I'm starting to like the Lua programming on CE, I want to do a visual interpreter of the values in the game and at first though of making it with GM and some dll to see the values and CE to search them before but now looks like CE will be enough for everything planned Smile

thanks Dark Byte and Co., keep the good work Very Happy
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