View previous topic :: View next topic |
Author |
Message |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Thu Oct 17, 2019 1:32 am Post subject: Batch creation and destruction |
|
|
Code: | for i=1,20 do
if P then P.destroy() end
P=createPanel()
end | The above code can only destroy the last one. How to destroy all of them?
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Thu Oct 17, 2019 2:42 am Post subject: |
|
|
use a table
Code: |
if P==nil then
P={}
end
for i=1,20 do
if P[i] then P.destroy() end
P[i]=createPanel()
end
|
_________________
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 |
|
 |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Thu Oct 17, 2019 2:59 am Post subject: |
|
|
Dark Byte wrote: | use a table |
Code: | if P==nil then
P={}
end
for i=1,5 do
if P[i] then P[i].destroy() end
P[i]=createForm()
P[i].setPosition(i*20,i*20)
end | I think so, but the information has been recorded in the table. If I modify for = 1,5 do, the previous form will not be destroyed.
|
|
Back to top |
|
 |
Dark Byte Site Admin
Reputation: 470
Joined: 09 May 2003 Posts: 25796 Location: The netherlands
|
Posted: Thu Oct 17, 2019 3:10 am Post subject: |
|
|
then do this:
Code: |
if P then
for x,y in pairs(P) do
y.destroy()
end
end
P={}
for i=1,5 do
P[i]=createForm()
P[i].OnClose=function() P[i]=nil return caFree end --only for forms
P[i].setPosition(i*20,i*20)
end
|
_________________
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 |
|
 |
.lua Expert Cheater
Reputation: 1
Joined: 13 Sep 2018 Posts: 202
|
Posted: Thu Oct 17, 2019 3:18 am Post subject: |
|
|
Dark Byte wrote: | then do this: | Your code is very good. This is the effect I want.Thank you very much
|
|
Back to top |
|
 |
|