Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Nequeo
Newbie


Joined: 02 Oct 2004
Posts: 3

PostPosted: Sat Oct 02, 2004 5:25 am   

#LOOPDB and #PROMPT - array too large?
 
Anyone have any ideas why this isn't working?

I have a variable, like so... generated automatically from the inventory.

Code:

#VAR item_cull {56021=wide conical hat made of bamboo|145720=storm cloak|225750 =plain silver ring}


I then want to ask which of these items are going to be enchanted, and for each item selected, which enchantment to use. So far I have an alias which does this:

Code:

#VAR prompt_keep {"p:'what would you like to enchant?'"}
#LOOPDB @item_cull {#ADDITEM prompt_keep {%val:~#ADDKEY item_keep ~{%key~=~"%val~"~}}}
#PICK {@prompt_keep}
#LOOPDB @item_keep {#PICK {p:Enchant %val with what:} {o:1} {firelash:#VAR item_keep.%key {firelash}} {firewall:#VAR item_keep.%key {firewall}}}


Now if I only select one item from @item_cull this script works perfectly, and I end up with something like this:

Code:

#VAR item_keep {225750=firelash}


But if I pick two or more items I get an error message 'Array too large' for every item but the last one. At the end of it, I'm left with something like this:

Code:

#VAR item_keep {56021=wide conical hat made of bamboo|225750=firelash}


I have tried this without the {o:1}, and with three different aliases instead of one with three commands. In each instance the result was the same. Worked fine for the first item, bugged out if there was more than one.

Any idea why this is happening, and how to fix it? Any help would be greatly appreciated.

Thanks!!
Reply with quote
Nequeo
Newbie


Joined: 02 Oct 2004
Posts: 3

PostPosted: Sat Oct 02, 2004 5:37 am   
 
#DOH

I'd still like to know what was causing this error, but I've found a solution. So simple that I'm a little embarrased I didn't try it before I posted. Must be getting late...

Code:

#LOOPDB @item_cull {#ADDITEM prompt_keep {%val:~#ADDKEY item_keep ~{%key~=~"%val~"~}}}
#PICK {@prompt_keep}
#LOOPDB @item_keep {#PICK {p:Enchant %val with what:} {firelash:#ADDKEY final_list {%key=firelash}} {firewall:#ADDKEY final_list {%key=firewall}}}


This works fine. It's a whole 'nother variable, but I can live with that.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Sat Oct 02, 2004 9:43 am   
 
Your problems probably start with @item_cull, which isn't a record variable and shouldn't be used with #LOOPDB. It's a list, so the loop command would be #FORALL. I'm not sure how you got anything to work, none of it worked for me until I fixed @item_cull.

The array problem is probably caused by your use of #VAR item_keep.%val {firelash} instead of #ADDKEY item_keep %val {firelash}. In this instance, %val is a number and varname.number is an alternate form of addressing arrays as well as an alternate form of addressing records.

Redone.
Code:
#UNV item_cull
#ADDK item_cull {56021=wide conical hat made of bamboo|145720=storm cloak|225750=plain silver ring}
#AL enchantlist {
#VAR prompt_keep {p:What would you like to enchant?}
#LOOPDB @item_cull {#ADDITEM prompt_keep {%val:#ADDKEY item_keep {%key=%val}}}
#PICK {@prompt_keep}
#LOOPDB @item_keep {#PICK {p:Enchant %val with what:} {o:1} {firelash:#ADDK item_keep %key {firelash}} {firewall:#ADDK item_keep %key {firewall}}}}
_________________
LightBulb
Senior member

Most scripts in this forum are written for Command Line entry.
Don't even open the Settings Editor unless its use is specified or obvious.
Reply with quote
Nequeo
Newbie


Joined: 02 Oct 2004
Posts: 3

PostPosted: Sat Oct 02, 2004 12:17 pm   
 
Quote:

Your problems probably start with @item_cull, which isn't a record variable and shouldn't be used with #LOOPDB.

Was too a record variable. I was just pretending to know more than I actually do, and also typing it up by hand instead of C/P from the class script. My bad.. Embarassed

Quote:

The array problem is probably caused by your use of #VAR item_keep.%val {firelash} instead of #ADDKEY item_keep %val {firelash}.


Yup, so it was. Both my bandaid fix and your tidier redone version avoided using item_keep.%val. Thanks very much for the input! Only problem now is that is but a miniscule snippet of a MUCH larger script, which frequently uses blah.%val in similar contexts, and so far hasn't had a problem. But I'm betting now would be a good time to back-track and correct those instances.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net