|
Nurodma |
Posted: Wed Nov 15, 2006 5:06 am
Importing Scripts From ZMud to CMUD |
|
Melindhra Newbie
Joined: 24 Sep 2005 Posts: 9 Location: Toronto
|
Posted: Sun Nov 19, 2006 11:43 pm |
Thanks. I'll try that. I've looked around somewhat, and this is the first time I've seen your suggestion. Hopefully that will work out better. Thanks again.
|
|
|
|
Melindhra Newbie
Joined: 24 Sep 2005 Posts: 9 Location: Toronto
|
Posted: Mon Nov 20, 2006 6:46 am |
I got a bit further this time, but I am having trouble figuring out where the unmatched braces at row 0, col 54 are in this block of code:
Code: |
#IF (@scripttorun = "combatambushing") {@peopleinroom = %1 @peopleinroom = %replace( @peopleinroom, " who is sitting, ", "|") @peopleinroom = %replace( @peopleinroom, " who is sitting", "|") @peopleinroom = %replace( @peopleinroom, " who is kneeling, ", "|") @peopleinroom = %replace( @peopleinroom, " who is kneeling", "|") @peopleinroom = %replace( @peopleinroom, " who is lying down, ", "|") @peopleinroom = %replace( @peopleinroom, " who is lying down", "|") @peopleinroom = %replace( @peopleinroom, ", and ", "|") @peopleinroom = %replace( @peopleinroom, ", ", "|")
#FORALL @peopleinroom {@peopleinroom = %replaceitem( %item( %replace( %i, " ", "|"), %numitems( %replace( %i, " ", "|"))), %ismember( %i, @peopleinroom), @peopleinroom)} @stealingfromnow = %item( @peopleinroom, 1)
#DELNITEM peopleinroom 1
hide
} |
Can someone give me an idea? Once I get this, I should be able to fix the rest. |
|
|
|
Guinn Wizard
Joined: 03 Mar 2001 Posts: 1127 Location: London
|
Posted: Mon Nov 20, 2006 10:21 am |
It just looks like really, really awful syntax ;)
#IF (@scripttorun = "combatambushing") {@peopleinroom = %1 @peopleinroom = %replace( @peopleinroom, " who is sitting, ", "|") ...
firstly '@peopleinroom = %1' isn't the right way of assigning a variable, it should be 'peopleinroom = %1'. Using @var = value is a cludge that zMUD allowed that Zugg's stamping out in CMUD so unless you're meaning to use indirect assignment, which doesn't look likely then use var = value. It's this that's showing you have unmatched braces - the braces are actually fine, it's just the dodgy assignments are confusing the parser.
then after that you just continue with another assignment, @peopleinroom = %replace( @peopleinroom, " who is sitting, ", "|")
where you should be separating commands by either ; or newlines.
The #FORALL looks like it makes sense, but then you're using @stealingfromnow = %item... after
So, all that said, the following will compile
Code: |
#IF (@scripttorun = "combatambushing") {
peopleinroom = %1
peopleinroom = %replace( @peopleinroom, " who is sitting, ", "|")
peopleinroom = %replace( @peopleinroom, " who is sitting", "|")
peopleinroom = %replace( @peopleinroom, " who is kneeling, ", "|")
peopleinroom = %replace( @peopleinroom, " who is kneeling", "|")
peopleinroom = %replace( @peopleinroom, " who is lying down, ", "|")
peopleinroom = %replace( @peopleinroom, " who is lying down", "|")
peopleinroom = %replace( @peopleinroom, ", and ", "|")
peopleinroom = %replace( @peopleinroom, ", ", "|")
#FORALL @peopleinroom {
peopleinroom = %replaceitem( %item( %replace( %i, " ", "|"), %numitems( %replace( %i, " ", "|"))), %ismember( %i, @peopleinroom), @peopleinroom)}
stealingfromnow = %item( @peopleinroom, 1)
#DELNITEM peopleinroom 1
hide
} |
To say again
Do not use: @var = value
Use this instead: var = value
Hope it helps ;)
Guinn |
|
_________________ CMUD Pro, Windows Vista x64
Core2 Q6600, 4GB RAM, GeForce 8800GT
Because you need it for text... ;) |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Nov 20, 2006 3:52 pm |
Also, #UPDATE isn't a valid command, so I'm not sure where you got that. The first error report that you mentioned said
"Syntax error in Alias: SaveData : unrecognized command."
so I'd look in your SaveData alias and when you try to compile it, it should tell you which command isn't valid. |
|
|
|
Melindhra Newbie
Joined: 24 Sep 2005 Posts: 9 Location: Toronto
|
Posted: Mon Nov 20, 2006 4:20 pm |
Guinn: Thanks. That worked. The problem with some of the code I have is that I did not write it all. On top of that, it's very old. However, I really, REALLY do not want to go through everything and rewrite it right now. Eventually, sure. Especially with some of the new functionality available in CMUD.
Some of the code is just so incredibly ugly that it gives me a headache to figure out what the original author was possibly thinking. Fortunately though, the code I wrote is fine. I just had to remove quotation marks around %1 variables and such.
Zugg: Thanks. I got rid of the #update command yesterday. I am pretty sure that the compiler didn't tell me which command wasn't valid, but I figured it out. Again, this is old code I'm working with. I have to go through it, but there is an incredible amount.
Part of the problem is that weird spacing (or lack thereof) got introduced when this code was imported and re-imported over the years, so that's why it looks so incredibly ugly. That's a big part of the reason that I stayed the heck away from it. |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Nov 20, 2006 6:00 pm |
Yes, I understand. And these are exactly some of the reasons why CMUD has stricter syntax so that people don't end up with such ugly and un-supportable scripts in the future. I understand that it will be painful to convert, but once you get it converted, then it should work much better and be easier to modify in the future. But I understand that this takes time and a lot of effort.
|
|
|
|
Tex Beginner
Joined: 16 Nov 2006 Posts: 21
|
Posted: Mon Nov 20, 2006 8:30 pm |
okay maybe someone can help me with a zmud trigger that appears to not work in in Cmud
and i know the variables are valid. ie spellup_temp = Hayseed and @spellup_checklevel=2 in this case
#TRIGGER {(%w) online since :} {#IF (@spellup_temp="%1" & @spellup_checklevel!="") {scrol}}
changed to
#TRIGGER {(%w) online since :} {#IF (@spellup_temp="%1" && @spellup_checklevel!="") {scrol}}
no luck, so i tried
#TRIGGER {(%w) online since :} {#IF (@spellup_temp="%1" && @spellup_checklevel!="") {scrol}} {#say trigger triggered}
trigger is working but apperntly my and isnt cause it always executes the #say
so i tried
#TRIGGER {(%w) online since :} {#IF ((@spellup_temp="%1") && (@spellup_checklevel!="")) {scrol}} {#say trigger triggererd but not working for %1}
any way the if statement is always coming up false.
Hayseed online since : Mon Nov 20 14:10:10 2006
trigger triggered but not working for Hayseed
again any help would be appreciated
Tex |
|
|
|
Larkin Wizard
Joined: 25 Mar 2003 Posts: 1113 Location: USA
|
Posted: Mon Nov 20, 2006 9:20 pm |
Try it without the quotes. When you put quotes around the %1, CMUD treats it as a literal %1 and doesn't expand the system variable. You shouldn't need any quotes at all, but if you want to enclose it, use curly braces instead.
|
|
|
|
Tex Beginner
Joined: 16 Nov 2006 Posts: 21
|
Posted: Mon Nov 20, 2006 9:33 pm |
thanks a ton, so should probably remove any other quotes that are in a similar trigger
Tex |
|
|
|
Tech GURU
Joined: 18 Oct 2000 Posts: 2733 Location: Atlanta, USA
|
Posted: Mon Nov 20, 2006 10:19 pm |
Yes... I tend to replace mine with { } if I think there could be spaces there that will throw off my scripts.
If you run the compatibility report you'll get these called out.
I gotta tell you Zugg, I'm in love with the report. It makes conversion a 100 times easier. |
|
_________________ Asati di tempari! |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Mon Nov 20, 2006 10:28 pm |
You don't need {} around %1 either. Spaces within %1 no longer cause the problems they did in zMUD.
Glad the compatibility report is helping! |
|
|
|
Tex Beginner
Joined: 16 Nov 2006 Posts: 21
|
Posted: Tue Nov 21, 2006 3:04 am |
Okay another can anyone help, this is an alias
givespell
spellotherperson=%1;#IF ( (%numwords( @spellup_others_yeslist, "|")>0) && (%1!="")) {#LOOP 1,%numwords( @spellup_others_yeslist, "|") {cast ~'%word( @spellup_others_yeslist, %i, "|")~' %1}} {#SAY %ansi( bright, red)No spells are selected for others.}
compatability report says
Alias givespell
%1 within quotes is not expanded [Help] : ")>0) && (%1!="
not sure how to fix it or if it needs fixing
Thanks
Tex |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Tue Nov 21, 2006 3:50 am |
my guess would be to add spaces between %1 and operators like !=.
|
|
_________________ EDIT: I didn't like my old signature |
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Nov 21, 2006 6:24 pm |
Remember that the compatibility report is "only a guideline". It doesn't do a formal syntax check, it just runs some regular expression pattern matches to try and identify possible problems. So sometimes you can trick it with complicated stuff like this. Since there is no way for it to count the quotes, it can't really tell which text is inside the quotes and which is outside the quotes.
In general, Matt is correct that your scripts will be more readable if you add some spaces around your && and != operators. |
|
|
|
Seb Wizard
Joined: 14 Aug 2004 Posts: 1269
|
Posted: Tue Nov 21, 2006 7:17 pm |
Zugg, maybe you should add something to the compatability report to this effect - so that people know to check on the "Compiled code" tab to confirm if there is a problem with their scripts...
|
|
|
|
Zugg MASTER
Joined: 25 Sep 2000 Posts: 23379 Location: Colorado, USA
|
Posted: Tue Nov 21, 2006 11:30 pm |
done
|
|
|
|
|
|
|
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
|
|