TinTin++ Mud Client The TinTin++ message board

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
TinTin++ Mud Client

Can't use functions inside of #sub?

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help
View previous topic :: View next topic  
Author Message
abedour



Joined: 29 Oct 2010
Posts: 33

PostPosted: Thu Sep 15, 2011 6:27 pm    Post subject: Can't use functions inside of #sub? Reply with quote

Code:
#sub {^Spell:%1: modifies %2 by %3 for %4 hours$} {<g22>@fcolor{%4} Spell<g06>:<ccc>%1<g06>: <g22>modifies<ccc> %2<g22> by<ccc> %3<g22> for @fcolor{%4}%4 <ccc>hours<088>} {4}
#sub {^%1: modifies %2 by %3 for %4 hours$} {<ccc>@fcolor{%4} %1<g06>:<g22> modifies<ccc> %2 <g22>by<ccc> %3<g22> for @fcolor{%4}%4 <ccc>hours<088>} {5}
#sub {^%1: modifies %2 by %3 permanently$} {<ccc>%1<g06>:<g22> modifies<ccc> %2 <g22>by<ccc> %3<g22> for @afcol{-1} <ccc>hours<088>} {5}
#sub {^Spell:%1: for %2 hours$} {<g22>@fcolor{%2} Spell<g06>:<ccc>%1<g06>: <g22>for @fcolor{%2}%2 <ccc>hours<088>}


Now, @afcol works great, coloring it just fine. So we won't get into that. However, I have the function @fcolor doing this:

Code:
#function {fcolor}
{
#switch {%1}
{
#case {0} {#return <faa>};
#case {1} {#return <fba>};
#case {2} {#return <fca>};
#case {3} {#return <ffa>};
#case {4} {#return <efa>};
#default {#return <fff>}
};
}


Now, I would expect it to return the word "Spell:" to the color corresponding to how many hours are left on the timer for it to drop. But it doesn't, it returns like this:

Code:
You are affected by the following:
 Spell:18: for 18 hours
 Spell:2: modifies hp by 50 for 2 hours
 2: modifies ac by 40 for 2 hours
 2: modifies hitroll by 3 for 2 hours
 2: modifies damroll by 6 for 2 hours
 Spell:29: modifies ac by -20 for 29 hours
 Spell:29: modifies ac by -20 for 29 hours
 Spell:15: for 15 hours


The "name" of the spell is replaced with how many hours are left, the colors are all RIGHT so to say, but everything is out of whack. It should read like this, (imagine it being colored correctly):

Code:
You are affected by the following:
Spell: detect invis   : for 17 hours
Spell: berserk        : modifies hp by 50 for 1 hours
                      : modifies ac by 40 for 1 hours
                      : modifies hitroll by 3 for 1 hours
                      : modifies damroll by 6 for 1 hours
Spell: shield         : modifies ac by -20 for 28 hours
Spell: armor          : modifies ac by -20 for 28 hours
Spell: mounted        : for 14 hours


Any ideas why this script could be messing with the output?
Back to top
View user's profile Send private message
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3274

PostPosted: Thu Sep 15, 2011 10:52 pm    Post subject: Reply with quote

Code:

#sub {^Spell:%1:

might need to be:
Code:

#sub {^ Spell:%1:


You can see if substitutions are triggering using: #debug sub on
Back to top
View user's profile Send private message Send e-mail
abedour



Joined: 29 Oct 2010
Posts: 33

PostPosted: Fri Sep 16, 2011 1:17 am    Post subject: Reply with quote

Well, they definitely 'trigger', since if I remove the @functions the colors I've added show up just fine and look great. Maybe it's a bug?
Back to top
View user's profile Send private message
F-3000



Joined: 06 Dec 2010
Posts: 63
Location: Next to polarbear

PostPosted: Fri Sep 16, 2011 3:51 am    Post subject: Reply with quote

It's a bug.

For some odd reason, the #function replaces the #sub's %1 with #function's %1.

When line is...
Code:
Spell: berserk        : modifies hp by 50 for 1 hours


Output should be:
Code:
<g22><fba>Spell<g06>:<ccc> berserk        <g06>: <g22>modifies<ccc> hp<g22> by<ccc> 50<g22> for <fba>1 <ccc>hours<088>


While it actually is:
Code:
<g22><fba>Spell<g06>:<ccc>1<g06>: <g22>modifies<ccc> hp<g22> by<ccc> 50<g22> for <fba>1 <ccc>hours<088>

(notice how the word "berserk" is replaced with number 1)
Back to top
View user's profile Send private message Visit poster's website AIM Address
Scandum
Site Admin


Joined: 03 Dec 2004
Posts: 3274

PostPosted: Fri Sep 16, 2011 7:31 am    Post subject: Reply with quote

My mistake, I see what you mean now. The function arguments are overwriting the substitution's arguments.

I've updated the beta source code with a fix.

http://tintin.sourceforge.net/download/tintin-beta.tar.gz
Back to top
View user's profile Send private message Send e-mail
abedour



Joined: 29 Oct 2010
Posts: 33

PostPosted: Fri Sep 16, 2011 8:46 am    Post subject: Reply with quote

You're awesome. Thank you.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Script Help All times are GMT - 5 Hours
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
Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads Get TinTin++ Mud Client at SourceForge.net. Fast, secure and Free Open Source software downloads
TinTin++ Homepage

Powered by phpBB © 2001, 2002 phpBB Group