Author Topic: How to destroy a variable or an object in Squirrel?  (Read 3402 times)

Oomek

  • Administrator
  • Sr. Member
  • *****
  • Posts: 311
  • Radek Dutkiewicz
    • View Profile
    • github.com/oomek
How to destroy a variable or an object in Squirrel?
« on: March 22, 2017, 09:50:43 AM »
I'm struggling to find a way to destroy an object or a variable.
when I make for example

Code: [Select]
local myText = fe.add_text()
How can I get rid of it from the screen apart from writing

Code: [Select]
myText.msg = ""
?

keilmillerjr

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1167
    • View Profile
Re: How to destroy a variable or an object in Squirrel?
« Reply #1 on: March 22, 2017, 02:33:17 PM »
I don't think you can remove a variable from memory, but you can destroy a variable by changing its type. I'm not sure if attract more would destroy the object on screen if you changed the variable type. You would have to test it. Assign your text object ass null during a transition and see what happens.

Oomek

  • Administrator
  • Sr. Member
  • *****
  • Posts: 311
  • Radek Dutkiewicz
    • View Profile
    • github.com/oomek
Re: How to destroy a variable or an object in Squirrel?
« Reply #2 on: March 22, 2017, 02:36:21 PM »
Assigning a variable to null does work as I cannot access it anymore, but the object does not disappear from the screen. I was trying to wipe it from the fe.obj table, but using .find() throws an error
« Last Edit: March 22, 2017, 05:45:31 PM by Oomek »

raygun

  • Administrator
  • Sr. Member
  • *****
  • Posts: 393
    • View Profile
Re: How to destroy a variable or an object in Squirrel?
« Reply #3 on: March 22, 2017, 05:30:39 PM »
you can't destroy attractmode objects from a script after they are created.  best thing to do is to set their visible attribute to false and just stop using them (or reuse them for something else)

cheers

Oomek

  • Administrator
  • Sr. Member
  • *****
  • Posts: 311
  • Radek Dutkiewicz
    • View Profile
    • github.com/oomek
Re: How to destroy a variable or an object in Squirrel?
« Reply #4 on: March 24, 2017, 07:10:13 PM »
you can't destroy attractmode objects from a script after they are created.  best thing to do is to set their visible attribute to false and just stop using them (or reuse them for something else)

cheers

I did as you suggested, thanks.