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 class

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Mon Feb 21, 2022 3:10 pm    Post subject: Lua class Reply with quote

Well i wanted to make local function that will set coords whenever player in foot or vehicle but when i made it it just say that there's error
Code:
local SetCoords = Vehicle:IsExist() and Vehicle:SetCoords or Player:SetCoords --giving me the error
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4702

PostPosted: Mon Feb 21, 2022 4:12 pm    Post subject: Reply with quote

https://www.lua.org/manual/5.3/manual.html#3.4.10
Quote:
The form
Code:
functioncall ::= prefixexp ‘:’ Name args

can be used to call "methods". A call v:name(args) is syntactic sugar for v.name(v,args), except that v is evaluated only once.

You have to invoke the function if you want to use the colon syntax.

Store the object and call SetCoords later, e.g. through a closure:
Code:
local obj = Vehicle:IsExist() and Vehicle or Player
local SetCoords = function(...) obj:SetCoords(...) end

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
Frouk
Grandmaster Cheater
Reputation: 5

Joined: 22 Jun 2021
Posts: 510

PostPosted: Mon Feb 21, 2022 11:20 pm    Post subject: Reply with quote

I'll try it later, rn i'm not home
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