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
tyh
Beginner


Joined: 01 Feb 2004
Posts: 24
Location: United Kingdom

PostPosted: Wed Feb 11, 2004 12:40 pm   

trouble with strings
 
My mud uses some two word spells that are causing me trouble.
Take a spell casting event : cast 'cure light' prisoner , no problem mud does what i want. Trying to build the string in an alias is a different matter.
Using @spellline = %concat("cast '", %1, "' ", %2 , " ", %3) puts cast 'cure light' prisoner into spellline but a subsequent @spellline to the mud results in it saying that the target is not present. it works fine with one word spells. Whats wrong?
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Wed Feb 11, 2004 4:42 pm   
 
That comes out to:
cast '%1' %2 %3
%1 is the spell.
%2 is the target.
What is %3?
If %1 is cure, %2 is light, and %3 is prisoner, then your command is "cast 'cure' light prisoner". The spell is "cure", which is probably unknown and the target is either "light" or "light prisoner" which is usually not present.

If you want an easy way to repeat the spell, just type it in correctly in the first place.
#AL c {@spellline = cast %-1;@spellline}
Type "c 'cure light' prisoner". The variable will contain "cast 'cure light' prisoner", and that's what will be sent to the MUD.
Reply with quote
tyh
Beginner


Joined: 01 Feb 2004
Posts: 24
Location: United Kingdom

PostPosted: Wed Feb 11, 2004 8:43 pm   
 
hmm, wont do the trick. I have two list variables, one with spell long names and one with spell shortnames. This is so i can use clw for 'cure light' for instance throughout. I have a function that returns the parenthisised long spell name from the inputed short name thus :

%concat( "'", %item( @fullspellnames, %ismember( %1, @shortSpellNames)), "'")

where the error lies is now trying to use the output , say 'cure light' in a spell casting line. The func is called getSpellName and i try to use it with the line : cast @getspellname(%1) %2 %3 in my alias, so -%1 wont work. It still produces the errors though of unknown target , where %1 is the shortspellname , %2 is a target (or blank) and %3 is an additional optional target (rarely used)
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Thu Feb 12, 2004 4:29 am   
 
Asking for a solution while withholding the details necessary to find one is a waste of time. If this doesn't solve your problem, please provide the alias(es), user-defined function(s), variables, and any other settings involved along with what you want to type and what you want sent to the MUD. It's a waste of everyone's time when you make us try to guess what you're doing.

One record-variable would be a much better choice than two matched list aliases. It's easier to create and maintain, and easier to use. Your user-defined function doesn't really seem to be necessary, just use the %item or %db directly.
To create a record-variable, use #ADDKEY.
#ADDKEY {spellnames} {clw} {cure light}

For two matched list-variables:
cast '%item( @fullspellnames, %ismember( %1, @shortSpellNames))' %2 %3

For one record-variable, with spell short names as the keys and long names as the values:
cast '%db( @spellnames, %1)' %2 %3

Finally, if you still want a user-defined function
For matched list-variables:
#FUN getspellname {%item( @fullspellnames, %ismember( %1, @shortSpellNames))}
Or for a record-variable:
#FUN getspellname {%db( @spellnames, %1)}
In either case, the function is used the same way:
cast '@getspellname( %1)' %2 %3

As you've probably noticed by now, the easy solution to getting ' where you want it is to put it there in the alias rather than the variable.
Reply with quote
tyh
Beginner


Joined: 01 Feb 2004
Posts: 24
Location: United Kingdom

PostPosted: Fri Feb 13, 2004 12:09 am   
 
Thats a bit clearer now yes. Still hasnt solved the problem though. However i set it up and however i place the quotes when it comes to a spell with a target it always reports that the target is not present. Spells without targets are firing off fine, single word'ers and double word'ers, just when a target is added I get nada. It seems to be asymptom of having the spellname in a variable somehow but just doesnt make sence. the variable should be expanded properly, perhaps its a setting I've got wrong?
Reply with quote
TonDiening
GURU


Joined: 26 Jul 2001
Posts: 1958
Location: Canada

PostPosted: Fri Feb 13, 2004 12:56 am   
 
Lets see what you have so far.
Paste the alias you are using

Paste you using that alias without a target
Paste the mud output showing it working.

Paste you using that alias with a target
Paste the mud output showing it not working.

Maybe someone can see something that is incorrect.
Reply with quote
tyh
Beginner


Joined: 01 Feb 2004
Posts: 24
Location: United Kingdom

PostPosted: Fri Feb 13, 2004 3:19 pm   
 
alias cc

#var casting 1
#var spellfail 0
#say spell @getspellname(%1) targ %2 targ 2 %3
cast '@getspellname(%1)' %2 %3

func getspellname as lightbulb above

cc armor

[*]<936hp 809sp 894st> spell armor targ targ 2
cast 'armor'
You begin to speak the words of the spell...

[*]<936hp 809sp 894st>
You have completed your casting.
You hear a high-pitched shriek as the air hardens around you.

cc clw friar

[*]<936hp 778sp 894st> spell cure light targ friar targ 2
cast 'cure light' friar
They aren't here.

[*]<936hp 799sp 894st> l friar
A tremble of fear creeps over you. The friar of Gath stands before you
in all his might with a flowing red robe and a black satin scarf draped over
it covered in holy markings. His mere presence demands authority and his
power is so overwhelming that just standing in his presence makes you feel
inadequate. He speaks with a calmness in his voice though which is soothing
and comforting, quite a contrast from his appearance.
He is a human approximately 5'8" tall.
The friar of Gath is in good health.
Reply with quote
tyh
Beginner


Joined: 01 Feb 2004
Posts: 24
Location: United Kingdom

PostPosted: Fri Feb 13, 2004 3:27 pm   
 
Also:

[*]<936hp 809sp 562st> cast 'cure light' me
You begin to speak the words of the spell...

[*]<936hp 809sp 562st>
You have completed your casting.
A warm, blue aura surrounds you for a moment, then softly fades.
You feel better!

cc clw me

[*]<936hp 743sp 644st> spell cure light targ me targ 2
cast 'cure light' me
They aren't here.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Feb 13, 2004 6:33 pm   
 
EDIT: Read my next reply before taking action
I'm sorry. If this is an accurate transcript from your MUD, then your MUD has a serious flaw and nobody here can help. Instead, you need to contact your IMM staff immediately, preferably the IMP and/or coder, and inform them that the MUD has a SERIOUS bug which needs immediate attention.

According to your transcript, you entered the exact same command twice.
cast 'cure light' me
The first time, the MUD recognized the spell and the target. The second time, it either didn't recognize the target or didn't parse the line correctly. Your spell list wouldn't have changed and with a target of "me" there is no chance that your target left the room. There is obviously a serious flaw in the MUD code, since it doesn't react consistently to identical commands under identical conditions.

You should understand that the MUD has no way to tell whether you type a command out at the keyboard or have an alias do it for you. All the MUD ever sees is the text you send to it. If you send:
cast 'cure light' me
the MUD cannot tell whether you typed:
cast 'cure light' me
or
cc clw me

The only other possibility is that this is not an accurate transcript.

BTW: "func getspellname as lightbulb above". Is it really so hard to paste a one-line script to the forum? I gave TWO suggested function scripts, and without specifying which one this is meaningless. However, the transcript makes clear that whichever one you used it's working correctly.
Reply with quote
LightBulb
MASTER


Joined: 28 Nov 2000
Posts: 4817
Location: USA

PostPosted: Fri Feb 13, 2004 7:39 pm   
 
Another possibility just occured to me. It might be the trailing space(s) from your alias which causes the problem.
"cast 'cure light' me"
is not the same as
"cast 'cure light' me "

You get a trailing space because you use "%2 %3", and even if there is no %3 you'll still send the space between them.

Aliases automatically append any unused parameters. Modify your alias to this:
#VAR casting 1
#VAR spellfail 0
cast '@getspellname(%1)'

DON'T use the #SAY. Because it uses %2 and %3, they would be removed from the "unused" category and would not be appended.

I still consider this to be a bug. The MUD should be able to handle trailing spaces. However, it's nowhere near as serious as I originally thought.
Reply with quote
tyh
Beginner


Joined: 01 Feb 2004
Posts: 24
Location: United Kingdom

PostPosted: Sat Feb 14, 2004 12:42 am   
 
Yep its that trail space messing up the target name. I decided to just cut the third parameter and go with the one target. Works how i want it now with recognizable customizable spell names and a generic mud alias. two target spells will have to be done in there own way...

thx muchly
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