Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Deleting 'player.' objects (https://forums.graalonline.com/forums/showthread.php?t=86150)

[email protected] 06-02-2009 07:16 PM

Deleting 'player.' objects
 
So, I'm storing items as

HTML Code:

  player.items.(id).(flag) = value;
Now, I'm wanting to delete the items from the player.items list
HTML Code:

  player.items.(@ temp.id).clearvars();
  player.items.(@ temp.id).clearemptyvars();
  player.items.(@ temp.id) = "";

Works fine, it clears all the sub flags of the object. Yay! However...

However, when I'm reading the objects var names, it's still showing the item ID in the list
HTML Code:

  player.items.getdynamicvarnames();
I thought using this
HTML Code:

  player.items.(@ temp.id) = "";
Would fix this, but it's not. Any ideas? thanks

salesman 06-02-2009 07:36 PM

I actually had a similar problem yesterday but Tig helped me out.

Try setting it to "" first, and then doing clearemptyvars();
PHP Code:

player.items.(@ temp.id) = "";
player.items.clearemptyvars(); 

Also, I think in your case you should make sure the .clearemptyvars() is being called on the player.items object not the player.items.(@ temp.id) object.

[email protected] 06-02-2009 07:45 PM

Works a charm- you rock! Thanks =D

zokemon 06-02-2009 11:45 PM

You can also do:

player.items.(@ temp.id) = new TStaticVar();
player.items.(@ temp.id).destroy();

Deletes the variable and all it's sub variables right there on the spot. You might have to do the player.items.(@ temp.id) = new TStaticVar(); before you add any subvariables to it though (which I always find is a good idea anyways if you are ever wanting to delete a mass of subvariables ever like so.

Inverness 06-03-2009 06:44 AM

I find the whole idea of Graal having subvariables like this.blah.blah2 without this.blah being an object is ridiculous and I avoid it at all cost.

cbk1994 06-03-2009 06:49 AM

Quote:

Originally Posted by Inverness (Post 1496614)
I find the whole idea of Graal having subvariables like this.blah.blah2 without this.blah being an object is ridiculous and I avoid it at all cost.

I also think it is rather odd, but I do not avoid it as you do. I wish Graal fully supported objects (similar to Java's implementation). Inheritance would be very useful.

[email protected] 06-03-2009 05:51 PM

Great help the lot of you, thanks guys! :)


All times are GMT +2. The time now is 06:55 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.