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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD Beta Forum
GeneralStonewall
Magician


Joined: 02 Feb 2004
Posts: 364
Location: USA

PostPosted: Sun Jun 27, 2010 9:13 am   

[3.21] How to force a json table to be created? Bug?
 
Is there a way to force a json table to be created for an existing variable?

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="test" copy="yes">
    <value>#var box_sides %null
#reset box_sides
#var box_sides</value>
  </alias>
  <var name="Box_Sides" usedef="true" copy="yes">
    <value>1=Bad|2=Bad|3=Bad|4=Bad|5=Bad</value>
    <default>1=Bad|2=Bad|3=Bad|4=Bad|5=Bad</default>
  </var>
</cmud>


Simply outputs:
Code:
Variable: + Box_Sides           (Auto)        1=Bad|2=Bad|3=Bad|4=Bad|5=Bad
Reply with quote
Zugg
MASTER


Joined: 25 Sep 2000
Posts: 23379
Location: Colorado, USA

PostPosted: Sun Jun 27, 2010 3:26 pm   
 
This is because your @Box_Sides variable is set as AutoType and not a StringList type. If you add "type="stringlist"" to the XML attributes then it will create the JSON table when you import it. Or use %vartype(box_sides,list).

If you have an existing string list in a string variable, you can create the json table using:

newvar = %json(@stringvar)

Normally you won't need to worry about this and once you set the proper variable type then the default value should work.

Also, you shouldn't really need to worry about this because the first time you use a list function (like %numitems, %item, etc) the variable will get converted to a string list automatically (thus, the "Auto" type) But until you use the variable, CMUD doesn't know whether to treat the AutoType as a string or as a string list.
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD Beta Forum 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