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
Morcelu
Newbie


Joined: 15 Aug 2006
Posts: 8

PostPosted: Sun Jan 04, 2009 12:16 am   

XML importing
 
Ok, I am completly lost, and yea CMud help files...leave something to be desired compared to the zmud help files I've been working on a database and alias combination for the past week

I want to be able to do my alias - <alias name="De">
<value>deadeyes @tar %db(@deadeyes,%1)%db(@deadeyes,%2)</value>
</alias>
</class>
that will work from my data base which currently looks like this
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
<var name="deadeyes" sorted="true"copy="yes">caw=cowardice|amn=amnesia|stu=stupidity|vert=vertigo|ble=bleed|confu=confusi
on|ano=anorexia|para=paralyse|maso=masochism|dem=dementia|pea=peace|ago=agorapho
bia|ml=manaleech|impat=impatience|rek=reckless|plag=plague|diz=dizzy|ast=asthma|
add=addiction|fe=fear|bl=blind|br=breach|sens=sensitivity|vomi=vomiting
|epi=epilepsy|clu=clumsy|sle=sleep|clau=claustrophobia</var>
</cmud>

I am currently unable to import that variable into Cmud, because when I tried looking for help on importing I could not find any information at all...so how do I import xml, how do I get my alias to work, I want to be able to do de *target* amn stu should do deadeyes amensia stupid but so far it either does deadeyes *target* everything in the variable or deadeyes *target* nothing

so any help at all would be Great because yea I could write this simple script in zmud no problem,but in cmud can't get anything to work
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Jan 04, 2009 1:15 am   
 
Copy the section in the code tags below. Open the Package Editor, right-click in the tree and select paste from the context menu.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <alias name="De" copy="yes">
    <value>#LOCAL $A,$B
#IF ((%numparam=3)||(%iskey(@deadeyes,%1)=0)) {
 tar=%1
 $A=%db(@deadeyes,%2)
 $B=%db(@deadeyes,%3)
} {
 $B=%db(@deadeyes,%2)
 $A=%db(@deadeyes,%1)
}
#IF ($B="") {$B=%item(%dbvalues(@deadeyes),%random(1,%numkeys(@deadeyes)))}
#IF ($A="") {$A=%item(%dbvalues(@deadeyes),%random(1,%numkeys(@deadeyes)))}
#SEND {deadeyes @tar $A $B}</value>
  </alias>
  <var name="deadeyes" type="Record" sorted="true" copy="yes">add=addiction|ago=agoraphobia|amn=amnesia|ano=anorexia|ast=asthma|bl=blind|ble=bleed|br=breach|caw=cowardice|clau=claustrophobia|clu=clumsy|confu=confusion|dem=dementia|diz=dizzy|epi=epilepsy|fe=fear|impat=impatience|maso=masochism|ml=manaleech|para=paralyse|pea=peace|plag=plague|rek=reckless|sens=sensitivity|sle=sleep|stu=stupidity|vert=vertigo|vomi=vomiting</var>
</cmud>
I would suggest getting rid of any matching settings first, but you could do it afterwards. I added a few things to the alias so that it will randomly select afflictions if you are in a rush. It allows you to type in quite a wide range of combinations including using 'de NewTarget' to tag them with 2 randoms. I would also suggest setting the Use Default on your "tar" variable for a small speed gain.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sun Jan 04, 2009 4:27 am   
 
Incidentally, you'll probably find it much easier to use the %begins function than a static database variable like that. Using %begins will allow you to leave off whatever letters you like, as long as the name's unique. You could either code the list in:

Code:
<func name="DeadEyeLongName">
  <value>#switch (%begins("cowardice",%1)) {#return "cowardice"}
  (%begins("amnesia",%1)) {#return "amnesia"}
  ...etc...
  (%begins("claustrophobia",%1)) {#return "claustrophobia"}
  {#return "invalid"}</value>
</func>


Or you could use a variable to store a list of afflictions:

Code:
<var name="DeadEyeList" type="StringList">cowardice|amnesia|...etc...|claustrophobia</var>
<func name="DeadEyeLongName">
  <value>#forall @DeadEyeList {#if %begins(%i,%1) {#return %i}};#return "invalid"</value>
</func>


Then your alias becomes:

deadeyes @tar @DeadEyeLongName(%1) @DeadEyeLongName(%2)

And your short names can be any unique string, so you don't need to remember which ones have three- and which have four-letter abbreviations, for example. I find it much better, anyway.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Morcelu
Newbie


Joined: 15 Aug 2006
Posts: 8

PostPosted: Mon Jan 05, 2009 3:27 pm   
 
Thanks for all the help guys, sorry haven't had a chance to get on the internet past couple of days, thank you though, I'll get to work on this right away.
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