PDA

View Full Version : Mudlib issue:


Chandler
02-27-2007, 09:10 PM
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?

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);

}

Riot
02-27-2007, 09:32 PM
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?

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:
for (temp.itemData: getstringkeys("this."))
temp.itemData.add(temp.itemData @"="@ makevar(@"this."@ temp.itemData));

You might want to change this to something like:
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:
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

Admins
02-28-2007, 12:19 AM
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

temp.newData.("item-"@ this.itemName) = temp.itemData;

). "new TGraalVar()" wont do anything either.

Chandler
02-28-2007, 08:27 AM
Right here:
for (temp.itemData: getstringkeys("this."))
temp.itemData.add(temp.itemData @"="@ makevar(@"this."@ temp.itemData));

You might want to change this to something like:
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:
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! :p


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

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. ^^

zokemon
02-28-2007, 10:55 AM
Oh, I see. I just see it being used, so I just use it. ^^

Are you sure you aren't thinking of new TStaticVar()?

Chandler
02-28-2007, 07:06 PM
Are you sure you aren't thinking of new TStaticVar()?
I don't think so, it could be though. :confused:

Inverness
03-01-2007, 03:10 AM
TStaticVar is what you're thinking of.
TGraalVars are just the normal variables.

zokemon
03-01-2007, 11:04 AM
TStaticVars let you use destroy() on them. ;)

Chandler
03-01-2007, 08:58 PM
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 ^^

zokemon
03-03-2007, 01:23 AM
Yeah, I saw that when I viewed the page. Thank you two for clearing that up ^^

Not a problem :)

cbk1994
03-04-2007, 05:44 AM
TStaticVars let you use destroy() on them. ;)

Hours and hours of fun