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


Joined: 20 Feb 2006
Posts: 2

PostPosted: Wed Nov 21, 2012 3:16 pm   

Alias Randomizer...please help? SOLVED
 
I will start by saying that I didn't write this, and I honestly don't really know how it works. It was written for me by a fellow mudder for Zmud, and I am now trying to copy it over to Cmud.

@tower_random = %random( 1, 8);@tower = %-1;@tower_string = %replace( @tower, ~", ~');#IF (@tower_random = 1) {towerooc ~{W*~{Ck~{cl~{wu~{ct~{Cz~{W* ~{w @tower_string};#IF (@tower_random = 2) {towerooc ~{w[~{gO~{Gs~{cc~{Ca~{Gr~{w] ~{W @tower_string};#IF (@tower_random = 3) {towerooc ~{W*~{RB~{re~{Rw~{ra~{Rr~{re~{YC~{yur~{Yt~{yse~{Yy~{W* @tower_string};#IF (@tower_random = 4) {towerooc ~{C~[~{WM~{woo~{Wn~{Ci~{ce~{C~]~{W @tower_string};#IF (@tower_random = 5) {towerooc ~{c[~{CB~{cik~{win~{Wi A~{wj~{ca~{Ch~{c]~{w:~{W @tower_string};#IF (@tower_random = 6) {towerooc ~{Y[~{gC~{Gh~{Ya~{gm~{ye~{Gl~{Ye~{yo~{gn ~{GG~{gr~{Ge~{ge~{Gn~{Y]~{C @tower_string};#IF (@tower_random = 7) {towerooc ~{C[~{WZ~{wom~{Wb~{Ci~{ce ~{WG~{wr~{We~{Ce~{cn~{C] ~{W @tower_string};#IF (@tower_random = 8) {towerooc ~{C/~{GB~{go~{cn~{Cd ~{CG~{ci~{gr~{Gl~{C/ ~{w @tower_string}

the command is "mook"

This works perfectly in Zmud, but obviously Cmud is a little different.

When I use this alias in Cmud I get this error: ERROR: Syntax error in Alias: mook : illegal token: = %random( 1, 8)

Can anyone help me convert this so that it'll work?

(yes, I have my aliases set to zscript)

Thanks so much in advance!


Last edited by Mellangell on Thu Nov 22, 2012 2:50 am; edited 1 time in total
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Wed Nov 21, 2012 4:50 pm   
 
1)In CMud, we use a multiline syntax for scripts rather than the command;command;command style used in ZMud. This makes things vastly more readable, which in turn makes it much easier to spot errors and makes other folk more willing to help. In the future, you will definitely want to convert zmud syntax like you received into this format (you can do this from inside CMud using the menu system in the Package Editor), particularly if you are coming to the cmud forums looking for help, offering help, or wanting to share a useful bit of script.

2)In CMud, when you want to assign a value to a variable using a=b syntax you cannot use @ in the variable name (that is @a=b is wrong). Remove the @ from the variable name for the first three lines. This is why you were getting the error messages.

3)Because of #1 and how ZMud/CMud parses things in general, CMud ignores unquoted whitespace. This means all the spaces separating the words being sent to the towerooc channel will probably be disappeared

4)check out the #SWITCH (new to cmud) or #CASE (from ZMud). These commands are more efficient than multiple #IF commands
_________________
EDIT: I didn't like my old signature
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Wed Nov 21, 2012 4:56 pm   
 
A #SWITCH would declutter your code a bit

#SWITCH (@tower_random) (1) {this} (2) {that} (3) {the other} {no match action}

also, you might wanna use #SENDRAW as well, to help with those rather clunky kludged channel messages

This makes a perfect opportunity for you to learn what the code does, you might be able to make a better script yourself
_________________
Discord: Shalimarwildcat
Reply with quote
Mellangell
Newbie


Joined: 20 Feb 2006
Posts: 2

PostPosted: Thu Nov 22, 2012 2:54 am   
 
Hi guys! thanks so much for taking the time to respond and help me out!

I read up on all your suggestions, (and you're right shalimar, I really should've taken the time sooner to learn how my stuff works), and I ended up going with #CASE, since that was the easiest for me to understand with my limited scripting knowledge.

The multiline syntax was SUPER helpful. lol

I'm going to keep reading up on scripting. Hopefully I'll eventually have a better understanding of how it work. :)
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