Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Objects. Love/Hate Relationship. (https://forums.graalonline.com/forums/showthread.php?t=74350)

killerogue 06-02-2007 09:03 AM

Objects. Love/Hate Relationship.
 
While enjoying my ability to come up with quirky names for threads. I'm having an issue elsewhere with me objects in my mudlib.

Here's the issue:

When I echo all the objects vars through the for loop. It only returns the values/information of the last two vars. This is causing a serious pain in the ass. Becuse no matter what I come up with. It refuses to return the values for all 3 object variables.

However, I know the variables are being written as getDynamicVarNames() returns all three vars. But I'm only getting the values for two.

Here's the script portion:

PHP Code:

public function reflectItems() {
  list = (
"Control_Mudlib").itemreflectvars;
  array.
clear();
  
  for (
05i++) {
    if (
files[i] == null) {
      break;
    }
    
    
item = new TStaticVar();
    
item.loadVars("mud/" files[i] @ ".arc");
    
    
obj = new TStaticVar();
    
obj.(@ list[i]) = makevar("item." @ list[i]);
        
    for (var : 
obj.getDynamicVarNames()) {
      echo(
obj.(@ var));
    }
  }



Twinny 06-02-2007 09:41 AM

Where is 'files' coming from?

killerogue 06-02-2007 10:02 AM

files is an array list of item names I set in an earlier function.

Novo 06-02-2007 11:05 AM

files - locations of lists...
lists - variables of concern...

What I see is this:

a) lists[ i ] is with respect to files[ i ] here... What you'd have to do is just:
PHP Code:

 for ( temp.var: list )
  
obj.(@ temp.var ) = item.(@ temp.var ); 

b) Variables might be reserved.

killerogue 06-02-2007 11:29 AM

Thanks Novo! Worked like a charm.

Inverness 06-02-2007 04:19 PM

Quote:

Originally Posted by killerogue (Post 1314445)
<stuff>

You look glad I released my scripts :D I can tell thats based on stuff I made.

You know, you don't have to initialize all objects to TStaticVar (but its good insurance), TGraalVar is variable after all.

Observe:
PHP Code:

public function saveItems() {
  
temp.file 0;
  
temp.0;
  
temp.path 0;
  
temp.data 0;
  
  
  for (
this.items.size() - 1> -1--) {
    if (
this.items[i].archname != null) {
      
data this.items[i].getSaveData();
      
file.(@ "item" data[0]) = {data[1], data[2], data[3]};
    }
  }
  
path MudControl.containerpath this.conttype "/cont" this.contid ".txt";
  
file.saveVars(path0);


file is not TStaticVar :P

Novo 06-02-2007 04:33 PM

Quote:

Originally Posted by Inverness (Post 1314515)
PHP Code:

  path MudControl.containerpath this.conttype "/cont" this.contid ".txt"


Umm... Shouldn't variables be MudControl.(@ containerpath @ this... ) instead?

I thought variables concatenations don't work that way.


All times are GMT +2. The time now is 08:25 AM.

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