TF

by ohtaren

Back to Mechanic's Corner.

ohtaren2005-02-02 16:28:35
Ok, this was being discussed on another thread and I thought it would be more apropriot here. I just got TF installed on my linux box and I wanted to start up some discussion on how to script with it. I am fluent in C but I don't know all the procedures required for this, or even what files to edit and such.

First question, how do I creat hotkeys in a unix terminal? my immidiate answer would be getch() or getchar() but those return an ascii int value and I want to capture multiple key presses at once, like ctl-num_pad-5. I also don't know how to send this key press capture to TF. any help?
Unknown2005-02-02 16:35:20
are you using the 5 beta or the 4 stable?
ohtaren2005-02-02 16:39:33
4 stable
Unknown2005-02-02 16:41:29
/bind ^5 = dosomethinghere

the tf documentation is really good....once you figure out how the hell to navigate around it.
Unknown2005-02-02 16:51:32
I just realised what you were actually asking, with tf you can do all the scripting internally it uses the .tfrc file which it loads on startup to set up your macros etc.

so as an example your .tfrc would have in it ...

/Def -b^5 = say Yey my first tf macro

...just so it doesnt confuse you /Def -b is the same as /bind
ohtaren2005-02-02 16:52:43
yeah when I first started it up I spend about 10 min trying to figure out how to get anything to happen. When thay said "/help" I thought there was a "help" directory in the TF directory, like any rational linux user. so of course, I CD tf/help and there isn't anything there...... grrrrr. oh well. I will read up on /help bind
Unknown2005-02-02 16:55:13
The command reference and user guide are also on line, if you find that easier to read at

http://tf.tcp.com/~hawkeye/tf/tf-40s1-help/

EDIT: oh and if you are real geek...like me.... and use vi, there is a VIM syntax file for tf scripting available at the website.
ohtaren2005-02-02 17:15:17
yeah I use VI. I was introduced to it by a guy that called it "six" I supose that is why they call Vissual Interface Imporved "VIM" instead of "VII like would be logical, they just didn't want people calling it "seven". Oh well, enough of the unix jokes. I need to figure all this stuff out
ohtaren2005-02-02 19:27:13
Ok I can't get triggers to work at all. I'm trying several different things. Here is what I've written to tfrc:

/def -t"(Aquamancers)" south = south

Just to test, the idea being that when someone speaks on the aquamancers channel I try and move south. I have also tried:

/trigger (Aquamancers) = south

and:

/hilite (Aquamancers)

None of these seem to work. anyone have any ideas? (btw I know that the tfrc file is loading properly and its in the right place because /addworld is the first line and it is doing that ok)
Unknown2005-02-02 19:44:48
/trigger is not like /def -t thats /trig

try this

/def -mregexp -t'^(Aquamancers):' = south
Estarra2005-02-02 19:53:20
It's been a looooong time since I wrote seriously in TF. But, for your amusement, here's part of a trigger file for TF written for ... another realm. Note that its completely outdated but maybe it'll help you with triggers.

QUOTE
/load echoes
/set eat_stat=0
/set last_eat="goldenseal"
/set last_smoke="valerian"
/set sileris_stat=0
/set selfish_stat=0
/set sleep_stat=0
/def save=/echo Save disabled.


/def heal = drink %{heal_potion}
/def mana = drink %{mana_potion}
/def mend = apply %{mend_potion} to %{1}
/def heat = apply %{caloric_potion}
/def sooth = apply %{epidermal_potion} to %{1}
/def immunity = drink %{immunity_potion}
/def bless = /smoke elm
/def irid = outb irid%;eat irid
/def sleep = /set sleep_stat=1%;focus%;sleep

/def smoke = /if (%{1} =~ "valerian") /smoke2 %{valerian_pipe} valerian%;\\
        /elseif (%{1} =~ "skullcap") /smoke2 %{skullcap_pipe} skullcap%;\\
        /elseif (%{1} =~ "elm") /smoke2 %{elm_pipe} elm%;\\
        /else /echo Unknown smoking reagant!%;/endif

/def smoke2 = /set last_smoke=%{2}%;light %{1}%;smoke %{1}

/def speed = drink %{speed_potion}
/def frost = drink %{frost_potion}
/def sileris = outb sileris%;apply sileris
/def kola = outb kola%;eat kola

/def loyal = focus%;focus%;touch tree%;insomnia%

/def fillval = outb valerian%;put valerian in %{valerian_pipe}%;inb valerian
/def fillskull = outb skullcap%;put skullcap in %{skullcap_pipe}%;inb skullcap
/def fillelm = outb elm%;put elm in %{elm_pipe}%;inb elm
/def fill = /fillval%;/fillskull%;/fillelm
/def preharmony = outb goldenseal%;outb goldenseal%;outb goldenseal
/def preconditioning = outb kelp%;outb kelp%;outb kelp

/def setup = /fill%;/preharmony%;/preconditioning%;insomnia%;touch cloak%;/speed%;
/heat%;/frost%;/sileris%;/kola%;telesense on%;selfishness%;/def -p3 -n1 -t'You hav
e recovered equilibrium.' = /setup4
/def setup4 = shroud%;/def -p3 -n1 -t'You have recovered equilibrium.' = /setup5
/def setup5 = lifevision%;/def -p3 -n1 -t'You have recovered equilibrium.' = /setu
p6
/def setup6 = soulmask%;/def -p3 -n1 -t'You have recovered equilibrium.' = /setup7
/def setup7 = touch mindseye%;/def -p3 -n1 -t'You have recovered equilibrium.' = /
setup8
/def setup8 = deathsight

/def eat = /set eat_type=%{1}%;/if (eat_type =~ "deathsight" | eat_type =~ "schola
stic") /eat3 %{1}%;\\
/else /eat2 %{1}%;/endif

/def eat2 = /if (eat_stat = 0) /set last_eat=%{1}%;/eat3 %{1}%;/set eat_stat=1%;\\
/else /set eat_stat=2%;/endif


/def eat3 = /if (%{1} =~ "sanity") /eat4 ash%;\\
                /elseif (%{1} =~ "harmony") /eat4 goldenseal%;\\
                /elseif (%{1} =~ "conditioning") /eat4 kelp%;\\
                /elseif (%{1} =~ "therapeutic") /eat4 lobelia%;\\
                /elseif (%{1} =~ "purifying") /eat4 ginseng%;\\
                /elseif (%{1} =~ "altruism") /eat4 bellwort%;\\
                /elseif (%{1} =~ "reaction") /eat4 bloodroot%;\\
                /elseif (%{1} =~ "deathsight") /eat4 skullcap%;\\
                /elseif (%{1} =~ "scholastic") /eat4 myrrh%;\\
                /else /eat4 %{1}%;/endif

/def eat4 = outb %{1}%;eat %{1}

/def generosity = /set selfish_stat=1%;generosity

/def -p1 -mglob -t'You may eat another general healing item.' = /if (eat_stat = 2)
/set \\
eat_stat=0%;/eat %{eat_type}%;/else /set eat_stat=0%;/endif

/def -p1 -mglob -t'* flays the sileris coating from you.' = /if (sileris_stat=0) o
utb \\
sileris%;apply sileris%;/set sileris_stat=1%;/repeat -3 1 /set sileris_stat=0%;/e
ndif

/def -p1 -mglob -t'*you legs out from under*' = stand

/def -p1 -mglob -t'Your nerves feel jangled all of a sudden*' = /eat harmony
Unknown2005-02-02 19:55:18
Eek. I keep forgetting Estarra played Achaea.
ohtaren2005-02-02 20:02:55
I tried that expression and it didn't work. Its pretty frustrating.
Unknown2005-02-02 20:10:28
Hahaha, purgative -> herb mappings. Oh ancient Achaen scripts, when will you fail to amuse?
Unknown2005-02-02 20:11:06
thats really strange, all I can think is you have somehow set your chance up strange

try

/trig '(Aquamancers):' = south

or

/trigc 100% '(Aquamancers):' = south

its very odd that its not going off
ohtaren2005-02-02 20:21:43
Ok I tried the first and second meathods that you suggested again. With the first one, it always attempts to go south when I type NSTAT. I assume this is because there is the line "Aquamancers:" but that line does not have the parenthasis, so that is really wierd. The second one does not work either way. am I meant to remove the single qoutes in the second meathod?
Unknown2005-02-02 20:24:04
*kick me*

you need to escape the (

so its


/def -mregexp -t'^\\(Aquamancers\\):' = south
ohtaren2005-02-02 20:30:47
woot it works! Thanks for your help. a couple questions though:

1) you use single quotes so that what I did and it works, but the examples in the help documents use double, whats the differance. In C single quotes are used for chars and double for stings, are the equivilent here?

2) you have the carrot at the beggining of the string, why? it isn't in the help file examples. what does it do.

3) should I always use -mregexp?
Unknown2005-02-02 20:33:12
the -mregexp switches the pattern matching from glob (shell) to regexp you can do this by setting the %matching variable soyou dont need to do the -m. The carrot is part of regexp it means this must be the start of the line (excluding a hook,i.e. the prompt). Single quotes and double should be all equivalent there is no reason one shouldnt work over the other, all it changes is what characters need escaping, strange that the doubles didnt work, but if singles do, just keep using them.
ohtaren2005-02-02 20:38:24
oh I didn't try the doubles, I was just wondering why you were using something other than the help files. I went straight to using the singles and didn't worry about it