|
cachew Novice
Joined: 10 May 2001 Posts: 39 Location: USA
|
Posted: Mon Apr 29, 2002 4:35 am
Help with a text replacement script |
Hello,
Sometime back I downloaded a script for medievia written by carabas. Using it as an example I attempted to write a script to replace a characters title. I have not been successful. I cannot seem to get it to alter any text displays. Anyone have an idea what I am doing wrong?
#CLASS {LevelShow}
#VARIABLE LevelShowSub {%2}
#TRIGGER {^(%w) the (*) is here};
#if ("%2" = "Believer") {#var LevelShowSub {1st Level Cleric}};
#if ("%2" = "Attendant") {#var LevelShowSub {2nd Level Cleric}};
#if ("%2" = "Acolyte") {#var LevelShowSub {3rd Level Cleric}};
#if ("%2" = "Novice") {#var LevelShowSub {4th Level Cleric}};
#if ("%2" = "Missionary") {#var LevelShowSub {5th Level Cleric}};
#if ("%2" = "Adept") {#var LevelShowSub {6th Level Cleric}};
#if ("%2" = "Deacon") {#var LevelShowSub {7th Level Cleric}};
#if ("%2" = "Vicar") {#var LevelShowSub {8th Level Cleric}};
#if ("%2" = "Priest") {#var LevelShowSub {9th Level Cleric}};
#if ("%2" = "Minister") {#var LevelShowSub {10th Level Cleric}};
#if ("%2" = "Canon") {#var LevelShowSub {11th Level Cleric}};
#if ("%2" = "Levite") {#var LevelShowSub {12th Level Cleric}};
#if ("%2" = "Curate") {#var LevelShowSub {13th Level Cleric}};
#if ("%2" = "Monk") {#var LevelShowSub {14th Level Cleric}};
#if ("%2" = "Healer") {#var LevelShowSub {15th Level Cleric}};
#if ("%2" = "Chaplain") {#var LevelShowSub {16th Level Cleric}};
#if ("%2" = "Expositor") {#var LevelShowSub {17th Level Cleric}};
#if ("%2" = "Bishop") {#var LevelShowSub {18th Level Cleric}};
#if ("%2" = "Arch Bishop") {#var LevelShowSub {19th Level Cleric}};
#if ("%2" = "Patriarch") {#var LevelShowSub {20th Level Cleric}};
#if ("%2" = "Elder Patriarch") {#var LevelShowSub {21st Level Cleric}};
#if ("%2" = "Grand Patriarch") {#var LevelShowSub {22nd Level Cleric}};
#if ("%2" = "Great Patriarch") {#var LevelShowSub {23rd Level Cleric}};
#if ("%2" = "Demon Killer") {#var LevelShowSub {24th Level Cleric}};
#if ("%2" = "Greater Demon Killer") {#var LevelShowSub {25th Level Cleric}};
#if ("%2" = "Avatar of an Immortal") {#var LevelShowSub {26th Level Cleric}};
#if ("%2" = "Avatar of a Deity") {#var LevelShowSub {27th Level Cleric}};
#if ("%2" = "Avatar of a Supremity") {#var LevelShowSub {28th Level Cleric}};
#if ("%2" = "Avatar of Implementors") {#var LevelShowSub {29th Level Cleric}};
#if ("%2" = "Master of all Divinity") {#var LevelShowSub {30th Level Cleric}};
#if ("%2" = "Cardinal Hero") {#var LevelShowSub {31st Level Cleric}};
#SUBSTITUTE {%1 the @LevelShowSub is here}
#CLASS 0
thanks
Christopher Chew |
|
|
|
LightBulb MASTER
Joined: 28 Nov 2000 Posts: 4817 Location: USA
|
Posted: Mon Apr 29, 2002 6:04 am |
I believe all the #IF commands and the #SUB command need to be actions taken in response to your #TRIGGER, not separate lines as you have them. I don't see any real purpose in the #VAR, it would be simpler to do the #SUB directly.
#TR {{^(%w) the (*) is here} {#IF ("%2" = "Believer") {#SUB {%1 the 1st Level Cleric is here}};#IF ("%2" = "Attendant") {#SUB {%1 the 2nd Level Cleric is here}};#IF ("%2" = "Acolyte") {#SUB {%1 the 3rd Level Cleric is here}};etc;#IF ("%2" = "Cardinal Hero") {#SUB {%1 the 31st Level Cleric is here}}}
LightBulb
All scripts untested unless otherwise noted |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Apr 29, 2002 7:09 am |
quote:
I believe all the #IF commands and the #SUB command need to be actions taken in response to your #TRIGGER, not separate lines as you have them. I don't see any real purpose in the #VAR, it would be simpler to do the #SUB directly.
#TR {{^(%w) the (*) is here} {#IF ("%2" = "Believer") {#SUB {%1 the 1st Level Cleric is here}};#IF ("%2" = "Attendant") {#SUB {%1 the 2nd Level Cleric is here}};#IF ("%2" = "Acolyte") {#SUB {%1 the 3rd Level Cleric is here}};etc;#IF ("%2" = "Cardinal Hero") {#SUB {%1 the 31st Level Cleric is here}}}
LightBulb
All scripts untested unless otherwise noted
Try this trigger out for size:
#trigger {^(%w the (*) is here} {
;this is shortened/simplified in such a way as to have no need of ordinal numbers
;if you wish to handle titles for other classes, simply make copies of the loop and divide the variables appropriately
#loop 1,%numitems(@titles) {#if (%2 = %item(@titles,%i)) {#sub {blah blah blah level %i cleric blah blah blah}} {#NOOP no match here, continue on}}
}
li'l shmoe of Dragon's Gate MUD |
|
|
|
cachew Novice
Joined: 10 May 2001 Posts: 39 Location: USA
|
Posted: Mon Apr 29, 2002 7:32 pm |
Gentlemen,
First, thanks for the help.
I am going to try the first example here in a little while. Matt, could you be a little more verbose with the second example .... I'm not that good of a coder so this is as much a learning exercise as it is game enhancement. Sorry for the being so dense ... I wish this came more natural.
In the vein of learning; would you (or anyone) know how to correct the first example?
thanks again
Christopher Chew |
|
|
|
Pega Magician
Joined: 08 Jan 2001 Posts: 341 Location: Singapore
|
Posted: Mon Apr 29, 2002 8:47 pm |
#CLASS {LevelShow}
#TRIGGER {^(%w) the (*) is here} {#VARIABLE LevelShowSub {%2};#if ("%2" = "Believer") {#var LevelShowSub {1st Level Cleric}};#if ("%2" = "Attendant") {#var LevelShowSub {2nd Level Cleric}};#if ("%2" = "Acolyte") {#var LevelShowSub {3rd Level Cleric}};#if ("%2" = "Novice") {#var LevelShowSub {4th Level Cleric}};#if ("%2" = "Missionary") {#var LevelShowSub {5th Level Cleric}};#if ("%2" = "Adept") {#var LevelShowSub {6th Level Cleric}};#if ("%2" = "Deacon") {#var LevelShowSub {7th Level Cleric}};#if ("%2" = "Vicar") {#var LevelShowSub {8th Level Cleric}};#if ("%2" = "Priest") {#var LevelShowSub {9th Level Cleric}};#if ("%2" = "Minister") {#var LevelShowSub {10th Level Cleric}};#if ("%2" = "Canon") {#var LevelShowSub {11th Level Cleric}};#if ("%2" = "Levite") {#var LevelShowSub {12th Level Cleric}};#if ("%2" = "Curate") {#var LevelShowSub {13th Level Cleric}};#if ("%2" = "Monk") {#var LevelShowSub {14th Level Cleric}};#if ("%2" = "Healer") {#var LevelShowSub {15th Level Cleric}};#if ("%2" = "Chaplain") {#var LevelShowSub {16th Level Cleric}};#if ("%2" = "Expositor") {#var LevelShowSub {17th Level Cleric}};#if ("%2" = "Bishop") {#var LevelShowSub {18th Level Cleric}};#if ("%2" = "Arch Bishop") {#var LevelShowSub {19th Level Cleric}};#if ("%2" = "Patriarch") {#var LevelShowSub {20th Level Cleric}};#if ("%2" = "Elder Patriarch") {#var LevelShowSub {21st Level Cleric}};#if ("%2" = "Grand Patriarch") {#var LevelShowSub {22nd Level Cleric}};#if ("%2" = "Great Patriarch") {#var LevelShowSub {23rd Level Cleric}};#if ("%2" = "Demon Killer") {#var LevelShowSub {24th Level Cleric}};#if ("%2" = "Greater Demon Killer") {#var LevelShowSub {25th Level Cleric}};#if ("%2" = "Avatar of an Immortal") {#var LevelShowSub {26th Level Cleric}};#if ("%2" = "Avatar of a Deity") {#var LevelShowSub {27th Level Cleric}};#if ("%2" = "Avatar of a Supremity") {#var LevelShowSub {28th Level Cleric}};#if ("%2" = "Avatar of Implementors") {#var LevelShowSub {29th Level Cleric}};#if ("%2" = "Master of all Divinity") {#var LevelShowSub {30th Level Cleric}};#if ("%2" = "Cardinal Hero") {#var LevelShowSub {31st Level Cleric}};#SUBSTITUTE {%1 the @LevelShowSub is here}}
#CLASS 0
NB: The Trigger command in this case is simply:
'#TRIGGER {parse text} {commands/text to send}'
Sometimes it consists of:
'#TRIGGER "trigger id" {parse/alarm/expression} {commands} {classname} flags'
It has to be entered on one line. The commands that the trigger responds with can only be expressed in multiple lines within the settings editor. |
|
|
|
cachew Novice
Joined: 10 May 2001 Posts: 39 Location: USA
|
Posted: Mon Apr 29, 2002 9:50 pm |
Thank you very much .... the initial example now works. I am going to try suggestions from both lightbulb and matt.
Christopher Chew |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon Apr 29, 2002 11:21 pm |
quote:
Matt, could you be a little more verbose with the second example .... I'm not that good of a coder so this is as much a learning exercise as it is game enhancement. Sorry for the being so dense ... I wish this came more natural.
I didn't change the basis of the #SUBSITUTE line, but since you had that part down pat I didn't bother recopying it in exact form. What I did change was the method of comparison, and that wasn't very much of a change.
The #LOOP command will execute the included commands multiple times, in this case a number equal to the number of items in the Titles variable. The #IF command works the same way those 31 #IFs do, in that if a match is found the if will send a #SUB line to the screen instead of just doing nothing.
All in all, basically all I did was tidy things up.
li'l shmoe of Dragon's Gate MUD |
|
|
|
|
|