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

Prefix/suffix echo.

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> Finished Scripts
View previous topic :: View next topic  
Author Message
titeuf



Joined: 29 Jul 2006
Posts: 84

PostPosted: Mon Mar 14, 2011 2:34 pm    Post subject: Prefix/suffix echo. Reply with quote

By default tintin++ shows the output of #ECHO and #SHOWME above the triggered line.

If you want to show something in front of, or after the line, you need to gag the whole line and echo it yourself, which can be tricky if you want to do this in separate aliases.

To fix that problem, I've made the following basic script:
Code:

#VAR currentline {};

#EVENT {RECEIVED LINE} {
    #VAR currentline {%1};
}

#ALIAS {^prefix %1$} {
    #ECHO {%1$curretline};
    #LINE GAG;
};

#ALIAS {^suffix %1$} {
    #ECHO {$currentline%1};
    #LINE GAG;
};



To see how it works:
Code:

#VAR hp 110;

#ALIAS {^warning$} {
    #IF {$hp < 100} {
        suffix   <119>WATCH OUT!<099>;
    };
};

#ACT {^Bad guy kicks you.$} {
    #MATH hp {$hp - 10};
    warning;
}

#ACT {^Bad guy slams his head into you.$} {
    #MATH hp {$hp - 50};
    warning;
}

#SHOWME Bad guy kicks you.
#SHOWME Bad guy kicks you.
#SHOWME Bad guy slams his head into you.
#SHOWME You died


This is very basic and limited (you can't use both suffix and prefix for instance), but it's good enough for me and I hope others get an use out of it too!
Back to top
View user's profile Send private message
F-3000



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

PostPosted: Tue Mar 15, 2011 2:36 am    Post subject: Reply with quote

With #SUBSTITUTE you can add stuff where-ever you wish on the line.

An example:
#substitute {%1 a blue pill$} {%0 <caf>-> detect invis 10h<088>}
Back to top
View user's profile Send private message Visit poster's website AIM Address
titeuf



Joined: 29 Jul 2006
Posts: 84

PostPosted: Tue Mar 15, 2011 12:00 pm    Post subject: Reply with quote

This works for simple things, but would fail already in my example: I only want to see the warning when my HP's too low.

Although I could use a function in the sub, that returns an empty string when your HP is high enough, otherwise the warning. That would work too. Not sure what would be better.
Back to top
View user's profile Send private message
LokiChaos



Joined: 27 Oct 2009
Posts: 61

PostPosted: Mon Apr 18, 2016 4:29 pm    Post subject: Reply with quote

I know this is old, but for prefixing, there is an easier way.

#echo {PREFIX\}

Example:
Code:

#act {FOOBAR} {#echo {WOMBATS\}}
em FOOBAR
WOMBATS[EM] FOOBAR


Suffixing ether requires the above or the #line gag; #echo {%0SUFFIX}
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 -> Finished Scripts 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