Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 04-07-2007, 09:15 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Array Copying Problems

READ MY POST BEFORE YOU MAKE YOURSELF LOOK STUPID

Ok, heres a little script thats part of the new mud system I'm working on.
PHP Code:
public function loadObject() {
  
temp.file 0;
  
temp.vars 0;
  
temp.0;
  
temp.0;
  
temp.0;
  
  
file = new TStaticVar();
  
file.loadvars(format("%s/%s/%s.txt"MudControl.mudpaththis.mudtypethis.mudid));
  
MudControl.loadRefs(file);
  echo(
"1:" file.muditems[0].mudid);
  echo(
"2:" file.muditems[1].mudid);
  
vars file.getVarNames();
  
vars.remove("mudid");
  
vars.remove("mudtype");
  
  for (
0vars.size(); ++) {
    
//if (file.(@ vars[i]).type() != 3) {
      
this.(@ vars[i]) = file.(@ vars[i]);
    
//}
    //else {
    //  s = file.(@ vars[i]).size();
    //  this.(@ vars[i]) = new [s];
    //  for (e = 0; e < s; e ++) {
    //    this.(@ vars[i])[e] = file.(@ vars[i])[e];
    //  }
    //}
  
}
  echo(
"3: " this.muditems[0].mudid);
  echo(
"4: " this.muditems[1].mudid);
  
file.destroy();
  
triggerAll("onLoadedObject"null);

Now heres my problem, when an object is loaded it contains reference strings like ref:item:20010 and ref:item:20011 which were the two objects I was using for this test. Now the MudControl parses all these strings and returns the correct MudObject# for them.

This works all find and dandy because in echos 1 and 2 it correctly displays the MudID under all conditions, meaning the reference parser is fine. Now my problem was that echos 3 and 4 were blank even though I was simply copying an already existing reference array.

Now previously in the object is another variable, the reference to the archetype which is just a single reference and not an array, this was copied to the current object just fine in all cases. Now when I tried to copy the array of the two items as a whole, it didn't work for some reason and echos 3 and 4 were blank as I said. Now then, what I did was add in the lines that you see commented out and the script worked fine after that.

Is this a bug or something?
__________________

Last edited by Inverness; 04-07-2007 at 10:48 PM..
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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