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
myddrun
Wanderer


Joined: 31 Mar 2005
Posts: 58

PostPosted: Mon Feb 08, 2010 1:34 pm   

creating variables in classes with out spamming #var
 
Sorry numpty of a post but i'm justing getting back in to messing with zmud. This is all about putting names in to variables in classes wiht out spamming 20-30 lines of #var in a script.

I create the many lists for each race and class of all players on the fly by spamming the mud's player info command.

So if for example there are let say no Fighters or Elves logged in, no Fighter or Elf variable is created.

Now here's the rub:

I dislike the idea of having bucket loads of #var's as I would need to initialise approximately 20-25 lists but as I use #Additem you can't put a variable in to a class with just #Additem alone..... OR CAN YOU?

From the mud's Player info command.

Example output
Name: Player Name
He is an Elven Fighter or
She is a Gnomish Druid Or
It is a Drow Mage etc

and my current code

Code:
Trigger{Name: (%w)}
{#var tempname %1}

#Cond {[He|She|It] is [a|an] (%w) (%w)}
{
#Additem %2 (@tempname,%2) /Race
#Additem %3 (@tempname,%3) /Guild
#unvar tempname
}


Would this work if i wanted to put them in to a class?

Code:
#Cond {[He|She|It] is [a|an] (%w) (%w)}
 {
    #IF (@%2) /if @race is not null
   {#Additem %2 (@tempname,%2)} /true

   {#var %2 {} {} classname
    #Additem %2 (@tempname,%2)} /false

    #IF (@%3) /if @class is not null
   {#Additem %3 (@tempname,%3)} /true

   {#var %3 {} {} classname
    #Additem %3 (@tempname,%3)} /false

#unvar tempname
}


for example, If @Fighter is not null #additem the player name.
If @fighter is null, create it in the class name, and then #Additem to it.

How would you do it?
Reply with quote
myddrun
Wanderer


Joined: 31 Mar 2005
Posts: 58

PostPosted: Tue Feb 09, 2010 8:49 am   
 
Ok so my code above was poor. :faceapalms:

I mustn't try to compose scripts while I'm at work and not thinking about it. Still after rewriting it at home it DID work so all good.
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