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 


Resetting a table in Lua?

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine Lua Scripting
View previous topic :: View next topic  
Author Message
Dr.Disrespect
Master Cheater
Reputation: 1

Joined: 17 Feb 2016
Posts: 490

PostPosted: Tue Mar 07, 2017 4:02 pm    Post subject: Resetting a table in Lua? Reply with quote

Say, if I have a table
Code:

table = {}


Is there a method like "table.clear()" in Lua to clear all the data in a table? Or do I have to do it manually, which means iterating through the whole table?

Thanks. Smile

Edit:

What if I do this? Will it cause memory leak?
Code:

table = {}

function test1()
   local t = {1,2}
   table = t
end

function test2()
   local t = {3,1}
   table = t
end


If I call "test1()" then "test2()", the data in "table" should be "3" and "1", right? If so, is there any memory leak? Is "table" only a pointer or not?

_________________
**************

A simple example is better then ten links. Very Happy


Last edited by Dr.Disrespect on Tue Mar 07, 2017 4:09 pm; edited 1 time in total
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 341

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

PostPosted: Tue Mar 07, 2017 4:07 pm    Post subject: This post has 1 review(s) Reply with quote

table={} will clear all fields inside it. (basically it assigns a new empty table to that variable}
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Back to top
View user's profile Send private message MSN Messenger
Dr.Disrespect
Master Cheater
Reputation: 1

Joined: 17 Feb 2016
Posts: 490

PostPosted: Tue Mar 07, 2017 4:09 pm    Post subject: Reply with quote

Dark Byte wrote:
table={} will clear all fields inside it. (basically it assigns a new empty table to that variable}


Thanks a lot, DB. Smile

_________________
**************

A simple example is better then ten links. 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