Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 02-27-2007, 09:10 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Mudlib issue:

Any reason why it isn't storing the array correctly? it should just save the "temp.newData" part as an array, however it refuses to do so! Any suggestions?
HTML Code:
function onCreated()
  {
  this.itemName = "Black Sword";
  this.itemDescription = "This great sword, once held by the almighty Chandler!";
  this.itemImage = "block.png";
  this.itemPrice = 300000;

  this.weaponName = "+Sword";
  this.causeEffect = {{"Poison", "Ice", "Fire"}, {100, 75, 75}};  
  
  for (temp.itemData: getstringkeys("this."))
    temp.itemData.add(temp.itemData @"="@ makevar(@"this."@ temp.itemData));
  
  temp.newData = new TGraalVar();
  makevar(@"temp.newData.item-"@ this.itemName) = temp.itemData;
  temp.newData.savevars("itemData/newItem.arc", 0);   
   
  }
Reply With Quote
  #2  
Old 02-27-2007, 09:32 PM
Riot Riot is offline
Delteria Management
Join Date: Nov 2003
Location: Seminole County, Florida
Posts: 280
Riot is on a distinguished road
Quote:
Originally Posted by Chandler View Post
Any reason why it isn't storing the array correctly? it should just save the "temp.newData" part as an array, however it refuses to do so! Any suggestions?
HTML Code:
function onCreated()
  {
  this.itemName = "Black Sword";
  this.itemDescription = "This great sword, once held by the almighty Chandler!";
  this.itemImage = "block.png";
  this.itemPrice = 300000;

  this.weaponName = "+Sword";
  this.causeEffect = {{"Poison", "Ice", "Fire"}, {100, 75, 75}};  
  
  for (temp.itemData: getstringkeys("this."))
    temp.itemData.add(temp.itemData @"="@ makevar(@"this."@ temp.itemData));
  
  temp.newData = new TGraalVar();
  makevar(@"temp.newData.item-"@ this.itemName) = temp.itemData;
  temp.newData.savevars("itemData/newItem.arc", 0);   
   
  }
Right here:
HTML Code:
  for (temp.itemData: getstringkeys("this."))
    temp.itemData.add(temp.itemData @"="@ makevar(@"this."@ temp.itemData));
You might want to change this to something like:
HTML Code:
for (temp.data: getstringkeys("this."))
    temp.itemData.add(temp.data @"="@ makevar(@"this."@ temp.data));
Using the same name as the variable in the foreach and as the variable you're adding too will not work as expected.

Changing to that makes this file on the server for me:
HTML Code:
item-Black Sword="causeEffect=""Poison,Ice,Fire"",""100,75,75""","itemDescription=This great sword, once held by the almighty Chandler!",itemImage=block.png,"itemName=Black Sword",itemPrice=300000,weaponName=+Sword
joinedclasses=
scriptlogmissingfunctions=false
timeout=0
Reply With Quote
  #3  
Old 02-28-2007, 12:19 AM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
To save an array you normally need to use savelines(). I am not sure for what also those makevars are used (e.g. you should write
PHP Code:
temp.newData.("item-"this.itemName) = temp.itemData
). "new TGraalVar()" wont do anything either.
Reply With Quote
  #4  
Old 02-28-2007, 08:27 AM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Quote:
Originally Posted by Riot View Post
Right here:
HTML Code:
  for (temp.itemData: getstringkeys("this."))
    temp.itemData.add(temp.itemData @"="@ makevar(@"this."@ temp.itemData));
You might want to change this to something like:
HTML Code:
for (temp.data: getstringkeys("this."))
    temp.itemData.add(temp.data @"="@ makevar(@"this."@ temp.data));
Using the same name as the variable in the foreach and as the variable you're adding too will not work as expected.

Changing to that makes this file on the server for me:
HTML Code:
item-Black Sword="causeEffect=""Poison,Ice,Fire"",""100,75,75""","itemDescription=This great sword, once held by the almighty Chandler!",itemImage=block.png,"itemName=Black Sword",itemPrice=300000,weaponName=+Sword
joinedclasses=
scriptlogmissingfunctions=false
timeout=0
Thank you!
I see now, thanks again!


Quote:
Originally Posted by Stefan View Post
To save an array you normally need to use savelines(). I am not sure for what also those makevars are used (e.g. you should write
PHP Code:
temp.newData.("item-"this.itemName) = temp.itemData
). "new TGraalVar()" wont do anything either.
Oh, I see. I just see it being used, so I just use it.
Reply With Quote
  #5  
Old 02-28-2007, 10:55 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Chandler View Post
Oh, I see. I just see it being used, so I just use it.
Are you sure you aren't thinking of new TStaticVar()?
__________________
Do it with a DON!
Reply With Quote
  #6  
Old 02-28-2007, 07:06 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Quote:
Originally Posted by zokemon View Post
Are you sure you aren't thinking of new TStaticVar()?
I don't think so, it could be though.
Reply With Quote
  #7  
Old 03-01-2007, 03:10 AM
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
TStaticVar is what you're thinking of.
TGraalVars are just the normal variables.
__________________
Reply With Quote
  #8  
Old 03-01-2007, 11:04 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
TStaticVars let you use destroy() on them.
__________________
Do it with a DON!
Reply With Quote
  #9  
Old 03-01-2007, 08:58 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Quote:
Originally Posted by Inverness View Post
TStaticVar is what you're thinking of.
TGraalVars are just the normal variables.
Yeah, I saw that when I viewed the page. Thank you two for clearing that up
Reply With Quote
  #10  
Old 03-03-2007, 01:23 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Chandler View Post
Yeah, I saw that when I viewed the page. Thank you two for clearing that up
Not a problem
__________________
Do it with a DON!
Reply With Quote
  #11  
Old 03-04-2007, 05:44 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by zokemon View Post
TStaticVars let you use destroy() on them.
Hours and hours of fun
__________________
Reply With Quote
Reply


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:30 PM.


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