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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
Genmiltiad
Newbie


Joined: 04 Jun 2010
Posts: 4

PostPosted: Sat Jun 05, 2010 3:50 am   

Not a great programmer-just a question here
 
Im trying to basically capture my inventory item IDs and item name and put them in 2 string list variables. I then display the variables in a seperate inventory window and clear out the lists so I can put new items in it next time it triggers. I am definately doing something wrong but not sure what I am doing. It actually will display the item ID and string name in the window in a list like I want but if I click the button I have setup and there is nothing in my inventory or the client isnt connected to the mud the client will crash. It has something to do with the strings being empty im sure but Im not sure what im doing. Any pointers here thanks? =)

-TRIGGER TO CAPTURE STRINGS-
#ADDITEM packidlist @itemid
#ADDITEM packnamelist @itemname

-ON BUTTON CLICK
#SEND "p pack"
#CLR
#SAY %CR

$numitems = %numitems(@packidlist)

$templistid = @packidlist
$templistname = @packnamelist

#UNTIL ($numitems = 0)
{#SAY %item($templistid,$numitems);
#SAY " "%item($templistname,$numitems);
$numitems = ($numitems - 1)}

$numitems = %numitems(@packidlist)

#UNTIL ($numitems = 0)
{#DELNITEM packidlist $numitems;
#DELNITEM packnamelist $numitems;
$numitems = ($numitems - 1)}
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Jun 05, 2010 3:54 am   
 
You should probably use %additem over #ADDITEM, otherwise this will fail if you have multiples of the same item with different IDs.
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Genmiltiad
Newbie


Joined: 04 Jun 2010
Posts: 4

PostPosted: Sat Jun 05, 2010 4:49 am   
 
Yeah I changed it to %additem and put some parts into funcitons with conditionals. It works now... except I have to click the button twice to update the inventory window correctly. Not sure why yet.

#SEND "p pack"
#CLR
#SAY %CR

$numitems = %numitems(@packidlist)

%if($numitems != 0,@outputlist(),)
%if($numitems != 0,@clearlist(),)
Reply with quote
ralgith
Sorcerer


Joined: 13 Jan 2006
Posts: 715

PostPosted: Sat Jun 05, 2010 4:21 pm   
 
I don't remember if CMUD does this (I think so), but can you view put your code for this into a class and then view the class and copy the whole code block, then paste it here inside [ code ] [ /code ] tags so we can see it?
_________________
CrossOver: Windows Compatibility on Mac and Linux CMUD Advocate
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Sat Jun 05, 2010 7:27 pm   
 
He doesn't need to do that. He can just switch to XML view, and copy and paste the XML version of the trigger, within the code tags.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD 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