Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Destroying an object in GS2? (https://forums.graalonline.com/forums/showthread.php?t=66377)

KuJi 06-01-2006 03:24 AM

Destroying an object in GS2?
 
I have been messing around w/ stuff, and was wondering how to clear this entire object.

hotel.room = "Rooms";
hotel.suite = "Suites";
hotel.master = "Master Suites";

Just some of the names, after that it contains
hotel.room.#.account
hotel.suite.#.account
hotel.master.#.account

and there could be like 500, and it only resets when you reconnect. How to destroy entire object?

I've tried: hotel.destroy();

napo_p2p 06-01-2006 03:53 AM

I guess one way would be to do:

PHP Code:

hotel = new TStaticVar();
hotel.foo "bar";
hotel.destroy(); 


ApothiX 06-01-2006 04:45 AM

or if it's not destroying because it has sub-members (which I don't really see why it would affect it, but just incase)

you could always try:

PHP Code:

for(temp.roomnumhotel.room.getvarnames()) {
  
hotel.room.(@temp.roomnum).destroy();
}
hotel.room.destroy(); 

likewise for the other types of rooms.
I don't think this will make much difference though. If you aren't declaring it as a TStaticVar(), then that is why it's not working, but if you are, try this anyway :P

KuJi 06-01-2006 05:59 AM

Quote:

Originally Posted by ApothiX
or if it's not destroying because it has sub-members (which I don't really see why it would affect it, but just incase)

you could always try:

PHP Code:

for(temp.roomnumhotel.room.getvarnames()) {
  
hotel.room.(@temp.roomnum).destroy();
}
hotel.room.destroy(); 

likewise for the other types of rooms.
I don't think this will make much difference though. If you aren't declaring it as a TStaticVar(), then that is why it's not working, but if you are, try this anyway :P

Hmm, I wasn't declaring it as such. Thanks both of you for help, first one helped more tho :p.

Still thanks

Loriel 06-01-2006 08:42 PM

hotel = 0; looks like it should work?

napo_p2p 06-01-2006 08:44 PM

Quote:

Originally Posted by Loriel
hotel = 0; looks like it should work?

It should. But probably only if 'hotel' is declared as an actual object (ie: a TStaticVar).

Skyld 06-01-2006 11:32 PM

Quote:

Originally Posted by napo_p2p
It should. But probably only if 'hotel' is declared as an actual object (ie: a TStaticVar).

You should probably declare it as an object before using it as an object anyway.

KuJi 06-02-2006 01:39 AM

I already got it working via declaring as object and then destroying.

Another Question:
With Tree Views, is it possible to get it so when I rightclick a guipopupmenu pops up w/ a list of options? Also, is there a way to detect if it is the last element of the tree?

First Element
Second Element
Third Element
Last Element <-- Needa Find

How to check for such?

Admins 06-02-2006 10:45 AM

I would say hotel = ""; would be enough :D
(if it's a normal variable then it and all its subvars will be deleted, if it's a TStaticVar then it will be deleted after a few moments if no other variable is linking to it anymore)

For the tree view menu:
PHP Code:

function MyTreeView.onOpenMenu(nodepathnamedotname) {
  if (
node.nodes.size()<=0)
    
MyContextMenu.open(mousescreenx,mousescreeny);



KuJi 06-03-2006 01:20 AM

Quote:

Originally Posted by Stefan
I would say hotel = ""; would be enough :D
(if it's a normal variable then it and all its subvars will be deleted, if it's a TStaticVar then it will be deleted after a few moments if no other variable is linking to it anymore)

For the tree view menu:
PHP Code:

function MyTreeView.onOpenMenu(nodepathnamedotname) {
  if (
node.nodes.size()<=0)
    
MyContextMenu.open(mousescreenx,mousescreeny);



Maybe I am doing it wrong:
I call it through:
PHP Code:

thiso.catchevent(name"onOpenMenu""onTreeView"); 

And I dont recieve function :(. And when I put obj, in front of node.. I recieved on anything even if it wasnt the end category :(
PHP Code:

function onTreeView(nodepathnamedotname) {
  if (
node.nodes.size() <= 0)
    
player.chat "test";



Skyld 06-03-2006 01:26 AM

Quote:

Originally Posted by KuJi
Maybe I am doing it wrong:
I call it through:
PHP Code:

thiso.catchevent(name"onOpenMenu""onTreeView"); 


I might be mistaken, but I thought catchevent requires an object?
PHP Code:

thiso.catchEvent(this"onOpenMenu""onTreeView"); 


Admins 06-03-2006 01:34 AM

You should try with TreeViewName.onOpenMenu first, if the name is not changing. Your code should work too, but may be the name is not good. First parameter will be obj then, node is second then.

KuJi 06-03-2006 01:39 AM

Quote:

Originally Posted by Stefan
You should try with TreeViewName.onOpenMenu first, if the name is not changing. Your code should work too, but may be the name is not good. First parameter will be obj then, node is second then.

What do you mean by that? Do I need to call it by an event or anything? When I check nodes size I keep getting 3

xXziroXx 06-03-2006 01:47 AM

Example:

PHP Code:

thiso.catchevent(this"onAction""onSlotPressed"); 


Then:

PHP Code:

function onSlotPressedobj ) {



KuJi 06-03-2006 01:59 AM

Quote:

Originally Posted by xXziroXx
Example:

PHP Code:

thiso.catchevent(this"onAction""onSlotPressed"); 


Then:

PHP Code:

function onSlotPressedobj ) {



Uhh.. you don't use this.. or Stefan didn't use this in the RC. They used name which is the name of the object... so

Skyld 06-03-2006 02:12 AM

Quote:

Originally Posted by KuJi
Uhh.. you don't use this.. or Stefan didn't use this in the RC. They used name which is the name of the object... so

PHP Code:

function onCreated()
{
  new 
GuiButtonCtrl("foo")
  {
    
// this. == button object
    
thiso.catchevent(this"onAction""onFoo");
  }
}

function 
foo(obj)
{
  
// obj. == button object



KuJi 06-03-2006 02:26 AM

Quote:

Originally Posted by Skyld
PHP Code:

function onCreated()
{
  new 
GuiButtonCtrl("foo")
  {
    
// this. == button object
    
thiso.catchevent(this"onAction""onFoo");
  }
}

function 
foo(obj)
{
  
// obj. == button object



name was used in replace of this for the RC stuff tho.

*Edit* Alright, now how can I find out which is the category before the selected node? *Edit*


All times are GMT +2. The time now is 01:59 PM.

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