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

passing commands to terminal

 
Post new topic   Reply to topic    The TinTin++ message board Forum Index -> General Discussion
View previous topic :: View next topic  
Author Message
techman246



Joined: 27 May 2013
Posts: 46

PostPosted: Mon May 27, 2013 9:22 pm    Post subject: passing commands to terminal Reply with quote

I am trying to code a soundpack for a game I play using tintin++ i have managed to make aliases with the #alias command but i was trying to make sounds like this: #if {laugh} {mplayer /home/$USER/"testing tin"/sounds/laugh.wav}
I read the manual and it says that the if statement is written #if {condition} {true} {false} and from what i understand {false} is optional. could i get some help with this problem? maybe #if is not the right way of accomplishing this. I don't really know
Back to top
View user's profile Send private message
LokiChaos



Joined: 27 Oct 2009
Posts: 61

PostPosted: Mon May 27, 2013 9:36 pm    Post subject: Reply with quote

If you want to run an external command, then you want #system

#system {mplayer /home/$USER/"testing tin"/sounds/laugh.wav >/dev/null 2>&1}

The latter parts are just to ensure all output is directed to /dev/null so it won't echo in the client.
Back to top
View user's profile Send private message
techman246



Joined: 27 May 2013
Posts: 46

PostPosted: Tue May 28, 2013 7:22 am    Post subject: that helped somewhat Reply with quote

I did manage to get the sound to play as long as i was not in the game. I tried writing an if like this #if {"laugh"} {#system {mplayer /home/$USER/"testing tin"/sounds/laugh.wav}} but my condition did not seem to work in the game. the laugh is the output from the mud and i think i need to take the output that the mud gives and set that as the condition but it still refuses to work. any thoughts?
Back to top
View user's profile Send private message
Slysven



Joined: 10 Apr 2011
Posts: 365
Location: As "Jomin al'Bara" in WoTMUD or Wiltshire, UK

PostPosted: Tue May 28, 2013 4:46 pm    Post subject: Reply with quote

What is the meaning of what you have as "laugh"? The first braced part of the #IF is the logical condition you wish to test, for instance if you want to test to see if a variable called laugh exists you could test for that with:
Code:
#IF {&{laugh}}
{stuff to do if true}
{optional stuff to do if false, don't even need the '{''}' if not needed};
or in the #ELSE form:
Code:
#IF {&{laugh}}
{stuff to do if true};
#ELSE
{stuff to do if false};


If you need to check a value held in a variable called laugh is, say, equal to 1 the first line would be:
Code:
#IF {$laugh==1}

alternatively, given that the false value is zero, you could test for the opposite of falsehood with:
Code:
#IF {$laugh}

PROVIDED that the variable exists...

If you are checking for a variable called laugh has a particular non-numeric value, say, "yes" you must use quotations around both the left and right side of the equality test condition "==" so it would be:
Code:
#IF {"$laugh"=="yes"}


Hope this gives you some ideas.

BTW, you may find it useful to play the sound effect in the background, by ending the #SYSTEM command with a '&' - the normal way to tell a unix command interpreter to run the command in the background, though you may also want to use the -really-quiet option to mplayer to avoid unwanted terminal text (or set the MPLAYER_VERBOSE environmental variable to 2 or less...) see the man pages for details.
Back to top
View user's profile Send private message
techman246



Joined: 27 May 2013
Posts: 46

PostPosted: Tue May 28, 2013 5:58 pm    Post subject: Reply with quote

Laugh is the output from the MUD eg you typr
laugh into the mud and it returns
you laugh
If another person types laugh you see
Person laughs
Im trying to make the keyword laugh play laugh.wav[/code]
Back to top
View user's profile Send private message
Slysven



Joined: 10 Apr 2011
Posts: 365
Location: As "Jomin al'Bara" in WoTMUD or Wiltshire, UK

PostPosted: Tue May 28, 2013 8:26 pm    Post subject: Reply with quote

Ah, something like:
Code:
#ACTION {^You laugh$}
{
    #SYSTEM {mplayer --really-quiet /home/$USER/"testing tin"/sounds/laugh.wav >/dev/null &}
}{7}

#ACTION {^%.%w laughs$}
{
    #SYSTEM {mplayer --really-quiet /home/$USER/"testing tin"/sounds/laugh.wav >/dev/null &}
}{7}
These pair of ACTIONS (I'd suggest a priority 7, lesser then the default of 5) priority should cause the sound to play if a line is received from the MUD server (or if you test it with a "#SHOWME {text that should match}"):
  • the exact text "You laugh" with no other characters before or after it on a line
  • a line containing just one word (of one or more letters) then a space and then "laughs"
Note that the '^' forces a match to the start of the line of text and the '$' the end, %. matches a single character and the %w zero or more letters of the alphabet. The reason for such a precise specification of the text to trigger the #ACTIONs on is to avoid false triggering from such output from the MUD server such as "Fred says: 'You laugh at my weapon at your peril!'" - read up on this and other TinTin++ commands when using TinTin++ with the #HELP command e.g.
Code:
#help action
Unlike Scandum's example I only send normal output from the mplayer command to the bitbucket (/dev/null) so that errors will still show up from that command if they arise.
Back to top
View user's profile Send private message
techman246



Joined: 27 May 2013
Posts: 46

PostPosted: Mon Jun 03, 2013 10:04 pm    Post subject: WORKED... one more issue Reply with quote

that worked perfectly but now i can't type while a sound is playing... any way to fix that? for example when the laugh sound is playing it will stop me from entering anything until the sound has stopped playing. if i try to enter text during the sound it will not enter the text... how can i fix this?
Back to top
View user's profile Send private message
Azirek



Joined: 29 Jan 2012
Posts: 28

PostPosted: Tue Jun 04, 2013 5:44 am    Post subject: Reply with quote

Code:

#system play -q file.wav

_________________
GNU Linux Slackware Current, Tintin++ 2.00.7 and 2.00.9
Back to top
View user's profile Send private message
techman246



Joined: 27 May 2013
Posts: 46

PostPosted: Tue Jun 04, 2013 11:48 am    Post subject: another issue Reply with quote

okay now i am having a problem with double string kind of things.
for example
Code:
The computer announces, "

is supposed to have the sound of
Code:
Announce.wav

whereas the line
Code:
The computer announces, "Hit on%w[/quote]
is supposed to have the sound
Code:
laser5.wav
any way i can make this happen? using the #action command in tintin???
Back to top
View user's profile Send private message
LokiChaos



Joined: 27 Oct 2009
Posts: 61

PostPosted: Tue Jun 04, 2013 2:54 pm    Post subject: Reply with quote

Either have two actions, and set the more exact one to a lower number (so higher priority) -or- use regex.
Code:

#act {The computer announces, "%*} {
#regex {%1} {Hit on%w"} {
play laser
} {
play announce
}
}


I find using regex to be cleaner, as tintin++ only has to check lines vs one action /then/ it can do more specific matching only when it's needed.
Back to top
View user's profile Send private message
techman246



Joined: 27 May 2013
Posts: 46

PostPosted: Wed Jun 05, 2013 2:10 pm    Post subject: okay another question Reply with quote

I have part of my sounds working now but how could i make the client not show the line of text but still play the sound for it?

for example The ship jerks slightly as its turrets are fired
plays laser.wav

what im wondering is how to make laser.wav play when the line is received but not show the line of text?
Back to top
View user's profile Send private message
Slysven



Joined: 10 Apr 2011
Posts: 365
Location: As "Jomin al'Bara" in WoTMUD or Wiltshire, UK

PostPosted: Wed Jun 05, 2013 8:51 pm    Post subject: Reply with quote

Just include "#LINE GAG" in the stuff that gets done in the #ACTION - that'll suppress the text that triggered the action.

BTW: I'm surprised that my previous post did not play the sounds "in the background" as that is what the '&' at the end of the #SYSTEM command is supposed to cause to happen. This is a *nix-ism and nothing to do with TinTin++ per say - I wonder if it is being clobbered somehow but I'm not sure how one might test that.... Confused
Back to top
View user's profile Send private message
techman246



Joined: 27 May 2013
Posts: 46

PostPosted: Thu Jun 06, 2013 8:41 am    Post subject: example please Reply with quote

I have tried this every way I can think of. One way it plays the sound but doesnt gag and the other way it gags but no sound.[/u]
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 -> General Discussion 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