|
Genmiltiad Newbie
Joined: 04 Jun 2010 Posts: 4
|
Posted: 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)} |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: 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 |
|
|
|
Genmiltiad Newbie
Joined: 04 Jun 2010 Posts: 4
|
Posted: 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(),) |
|
|
|
ralgith Sorcerer
Joined: 13 Jan 2006 Posts: 715
|
Posted: 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 |
|
|
|
Rahab Wizard
Joined: 22 Mar 2007 Posts: 2320
|
Posted: 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.
|
|
|
|
|
|