![](templates/Classic/images/spacer.gif) |
Elvnik Newbie
Joined: 01 Jul 2007 Posts: 5
|
Posted: Mon Jul 02, 2007 2:59 am
function problem |
Hi,
id like to create a function, which displays my combat messages in a somewhat shorter format (my mud is spammy)
i created several triggers which capture the relevant information and then i'd like to call a function from every trigger body,
to display the new combat messages via #show.
the function right now gets 3 parameters.
everything worked fine, as long as i took the #alias command to get it working, i gave the alias command 3 parameters, and it displayed my new
combat message. But the alias is interpreted to slow. I get the "mob is DEAD. R.I.P" message before the last combat message.
my tries with functions all resulted in failures:
i think the main problem is, my function is fairly complicated, lots of string concatenating, inserting ansi-colors and format-printing.
i was unable in zMud io create a #FU {} or a #VA "" (the #FU was somehow autoconverted into a #VA, and the #VA simply was not working, the "" made problems)
Now i installed CMUD, and was looking forward to test the function syntax here.
But im stuck in giving the parameters to my #VAR display_damage
Code: |
msg_hitter=%trim($hitter)
msg_text=%trim($text)
msg_gothit=%trim($gothit)
|
the only response i get im the compiled code tab:
Code: |
Error compiling script:
unmatched braces
|
im totally clueless now ...
If anyone can help here, its really appreciated. Especially working samples !
If you have other suggestions, feel free to comment.
regards,
Elvnik[/code] |
|
|
![](templates/Classic/images/spacer.gif) |
Elvnik Newbie
Joined: 01 Jul 2007 Posts: 5
|
Posted: Mon Jul 02, 2007 3:02 am |
i forgot:
the variable type is: String(expanded)
the named params are defined as: hitter,text,gothit |
|
|
![](templates/Classic/images/spacer.gif) |
Fang Xianfu GURU
![](images/avatars/1763170544a2093e7e85da.gif)
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Jul 02, 2007 9:55 am |
Functions are currently stored as variables, that's not a bug or a problem. This will change in the future, hopefully in the next version due out around the end of the month.
Functions in CMUD (and zMUD) aren't functions like you'd find in any other language. Functions don't execute any commands - they only evaluate functions inside them and return the result. This will change in the future. This still gives you some quite powerful stuff you can do with functions (%additem, %exec and so on all work) but since there's also no #return command for use in functions to customise exactly what gets returned. Here's an example of what should be a working function off the top of my head:
#fu help_link($name,$short) {%concat("<send HELP_",$name,">",%if($short,"HELP_"),%upper($name),"</send>")}
notice how there are no commands, just the return of the %concat function that's passed along. Functions work basically as a shorthand for long strings of zScript functions - it's as if you just pasted that line into your script every time you used the @help_link() function. In the next version, there'll hopefully be "real" functions. It's on the to-do list. |
|
|
![](templates/Classic/images/spacer.gif) |
|
|
|
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
|
|