Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Object NOT Loading Vars >_> (https://forums.graalonline.com/forums/showthread.php?t=74413)

killerogue 06-05-2007 10:29 PM

Object NOT Loading Vars >_>
 
First off here's the part of the function in the class:

PHP Code:

function reflectItem(archpresufid)
{
  echo(
"[ItemReflect]");
  
file = new TStaticVar();
  
TObj = new TStaticVar();
  
TObj.id id;
  
TObj.qty this.item.qty
  if (
this.item != NULL) {
    echo(
"Object exists");
    
file.loadVars("mud/archetypes/" arch ".arc"); // Problem found, file is not loading the vars.
      
echo(file.getVarNames());
    echo(
"Loaded vars and removed vars...");
    for(var : 
file.getDynamicVarNames()) {
      
TObj.(@ var) = file.(@ var);
      echo(
"[ItemReflect]:" SPC var @ "=" file.(@ var));
    }
  } 


The problem is, the "file" object is not returning any of the vars it's loading. >_> What the hell is going on here.

Inverness 06-05-2007 10:50 PM

You sure like to butcher the scripts I give you. Anyhow, make sure npcserver has rights to the folder. Also, you need to declare your temp variables are the beginning of the script X_X

killerogue 06-05-2007 10:55 PM

Quote:

Originally Posted by Inverness (Post 1315433)
You sure like to butcher the scripts I give you. Anyhow, make sure npcserver has rights to the folder. Also, you need to declare your temp variables are the beginning of the script X_X

This isn't the one you helped me with, this is something different Chompy and I were working on together.

Edit: Npc server already had rights to the necessary folders and declaring the vars temp prior to fixed nothing. :[

Super Edit: Problem was identified in another class.

killerogue 06-05-2007 11:55 PM

The 'True' Problem
 
PHP Code:

public function loadItems()
{
  
temp.data 0;
  
temp.file 0;

  
path format(MudControl.charitems "%s.arc"this.account);
  
file.loadVars(path);
  
  
with (file) {
    
keys getstringkeys("this.item");
    echo(
keys);
  }
    
  for (
0keys.size(); i++) {
    
data.clear();
    
data file.(@ "item" keys[i]);
    echo(
data[0]);
      
loadItem(idata[0], data[3], data[1], data[2]);
  }


Zeroed in on the true problem with the help of Chandler, the vars are being properly send to the function that calls what I first posted. loadItem is that function.

Here's the issue, the data line. When echoing "data" or "data[0]" it returns the entire array where as "data[1] - data[3]" return zero when they shouldn't. >_>


Edit: Didn't Inverness have this same issue with copying arrays? -.-

Inverness 06-06-2007 04:17 AM

You seem to be quite good at editing my scripts and breaking them in the process =P

killerogue 06-06-2007 04:28 AM

Quote:

Originally Posted by Inverness (Post 1315489)
You seem to be quite good at editing my scripts and breaking them in the process =P

Didn't edit yours! :[

Angel_Light 06-06-2007 04:31 AM

Quote:

Originally Posted by Inverness (Post 1315489)
You seem to be quite good at editing my scripts and breaking them in the process =P

Thats how learn how to script, XD Napo gave me your script and I would "play" with them. :P Oh and are you sure your 'lining up" the variables correctly?

killerogue 06-06-2007 04:37 AM

Ugh, none of that is the problem. The problem is when I'm trying to put the vars in the array. It creates a multidemensional array rather than fill it up.

EXAMPLE:

array 2 = {"crap", "foo", "bar",}
array1.clear();

array1 = array2;

It's returning array 1 like in on of these:

array1 = {array2, array2, array2}

And has array two set as all the indices.

or

Just sets array2 as the first index. But the idea is for:

array 1 = array 2
array1 should end up equalling {"crap", "foo", "bar"}

Angel_Light 06-06-2007 01:25 PM

Ah, I remember a buddy of mine had this problem he had to put something infront of array2

array1 = something(array2);

Sorry don't remember what, hope that helps any. :/

zokemon 06-06-2007 03:20 PM

Maybe it isn't saving right? If you are using add(), try doing addarray() instead (like if you were using it in the file saving). Does the file you are loading from have quotes in the variables?

Inverness 06-06-2007 08:31 PM

Stop using clear(), its unnecessary
And show me the file you're loading from.

Admins 06-06-2007 09:23 PM

Assigning one array to another is working fine.
When you only get stuff in data[0] or data then it is probably not an array, eventually the item data is not a correct comma-separated list (manually edited?). It must be text,"item name",text instead of text,item name,text

zokemon 06-07-2007 12:26 AM

Quote:

Originally Posted by Stefan (Post 1315709)
Assigning one array to another is working fine.
When you only get stuff in data[0] or data then it is probably not an array, eventually the item data is not a correct comma-separated list (manually edited?). It must be text,"item name",text instead of text,item name,text

Yeah if you have something like this in the file:

varname="text,text,text"

It will give you (in GS2 terms): varname = {{"text", "text", "text"}};
As you can see that is an array inside an array so what you want is:

varname=text,text,text

killerogue 06-07-2007 03:06 AM

Zero and Stefan perfectly fixed my problems. :D Thanks guys for all your help. Inside the file the var wasn't an array, it was a string. >_> :D

zokemon 06-07-2007 09:28 AM

No problem :)


All times are GMT +2. The time now is 11:02 PM.

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