www.ClassicTW.com
https://mail.black-squirrel.com/

Read SWATH Config II
https://mail.black-squirrel.com/viewtopic.php?f=15&t=17735
Page 1 of 1

Author:  Promethius [ Tue Sep 05, 2006 7:01 am ]
Post subject: 

Since there was some interest in this script I formatted the window that displays the triggers and macros being used in SWATH. I also added a check to determine if the path was correct and give an error message if it didn't find the file.

I also added a few comments to the script.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

# swathcfg.ts - Promethius Sept 2006
# display swath macros and triggers in a window

setVar $SWATHcfg "C:\Program Files\SWATH 1.8.3\SWATH.cfg"

# check for a valid path to swath.cfg
fileExists $validPath $SWATHcfg

if ($validPath = 0)
clientmessage "Could not find the path to SWATH.CFG"
clientmessage "Current path: " & $SWATHcfg
clientmessage "Change the path above!"
halt
end

# path was valid, init some Vars and setup window

setVar $mac 0
setVar $action 0
setVar $key 0
Window cfg 425 525 " CRS --- Swath Config by Promethius " ONTOP
setVar $cfgWindow ""

# Read the file
if ($SWATHcfg <> 0)
read $SWATHcfg $eofChk 1
setVar $i 1
while ($eofChk <> EOF)
getword $eofchk $chk 1
if ($chk = "<Macro") and ($chk <> "<Macros")
add $mac 1
getword $eofChk $macroID[$mac] 2
stripText $macroID[$mac] "id="
stripText $macroID[$mac] ">"
getText $eofChk $macroName[$mac] "name=" ">"
getText $eofChk $macroString[$mac] ">" "</"
add $numMacrosInFile 1
elseif ($chk = "<Event")
add $key 1
gettext $eofChk $event[$key] "key=" " mod"
getText $eofChk $mod[$key] "mod=" "/>"

elseif ($chk = "<Action")
add $action 1
getText $eofChk $atype[$action] "type=" ">"
gettext $eofChk $actionScript[$action] ">" "</Action"
end
add $i 1
read $SWATHcfg $eofChk $i
end
end

# done with file, setup Var for macros

setVar $i 1
setVar $cfgWindow "**-=-= Macros =-=-*"
while ($i <= $mac)
setVar $cfgWindow $cfgWindow & " " & $macroName[$i] & " " & $macroString[$i] & "*"
add $i 1
end

# done with macros, setup Var for scripts

setVar $i 1
setVar $cfgWindow $cfgWindow & "**-=-= Events =-=-*"
gosub :keycodes
while ($i <= $key)
setVar $dispEvent ""
stripText $atype[$i] #034
setVar $script ""
if ($atype[$i] = "65796") or ($atype[$i] = "65793")
setVar $script "Yes"
end
stripText $event[$i] #034
setVar $dispEvent $event[$i]
getWordPos $mod[$i] $shift 1
setVar $modKey ""
if ($shift > 0)
setVar $modkey "Shift-"
else
getwordpos $mod[$i] $shift 4
if ($shift > 0)
setVar $modkey "ALT-"
end
end
getwordpos $mod[$i] $shift 2
if ($shift > 0)
setVar $modkey "CTRL-"
end
setVar $format $modkey & $keys[$dispEvent]
gosub :padRight
if ($script = "Yes")
setVar $cfgWindow $cfgWindow & " " & $format & " " & $actionScript[$i] & "*"
# setVar $cfgWindow $cfgWindow & " " & $modkey & $keys[$dispEvent] & " " & $actionScript[$i] & "*"
else
setVar $imac 1
while ($imac <= $mac)
getwordpos $macroID[$imac] $macPos $actionscript[$i]
if ($macPos > 0)
setVar $cfgWindow $cfgWindow & " " & $format & " " & $macroName[$imac] & " " & $macroString[$imac] & "*"
end
add $imac 1
end
end
add $i 1
end

# put everything into the window

setWindowContents cfg $cfgWindow

# setup a trigger that should not show up in a game, but since it is in
# this public script - you might want to change it

setTextTrigger lmao :lmao "xyzzy"
pause
halt

# make the trigger keys the same width if less than width <= 10
:padRight
getLength $format $len
while ($len <= 10)
setVar $format $format & " "
add $len 1
end
return

# don't know where the hell these codes came from

:keyCodes
setVar $keys[112] "F1"
setVar $keys[113] "F2"
setVar $keys[114] "F3"
setVar $keys[115] "F4"
setVar $keys[116] "F5"
setVar $keys[117] "F6"
setVar $keys[118] "F7"
setVar $keys[119] "F8"
setVar $keys[120] "F9"
setVar $keys[121] "F10"
setVar $keys[122] "F11"
setVar $keys[123] "F12"
setVar $keys[187] "="
setVar $keys[189] "-"
setVar $keys[192] "`"
setVar $keys[48] "0"
setVar $keys[49] "1"
setVar $keys[50] "2"
setVar $keys[51] "3"
setVar $keys[52] "4"
setVar $keys[53] "5"
setVar $keys[54] "6"
setVar $keys[55] "7"
setVar $keys[56] "8"
setVar $keys[57] "9"
setVar $keys[65] "A"
setVar $keys[66] "B"
setVar $keys[67] "C"
setVar $keys[68] "D"
setVar $keys[69] "E"
setVar $keys[70] "F"
setVar $keys[71] "G"
setVar $keys[72] "H"
setVar $keys[73] "I"
setVar $keys[74] "J"
setVar $keys[75] "K"
setVar $keys[76] "L"
setVar $keys[77] "M"
setVar $keys[78] "N"
setVar $keys[79] "O"
setVar $keys[80] "P"
setVar $keys[81] "Q"
setVar $keys[82] "R"
setVar $keys[83] "S"
setVar $keys[84] "T"
setVar $keys[85] "U"
setVar $keys[86] "V"
setVar $keys[87] "W"
setVar $keys[88] "X"
setVar $keys[89] "Y"
setVar $keys[90] "Z"
return

Author:  Maverick2002 [ Tue Sep 05, 2006 10:16 pm ]
Post subject: 

Works great. I use the button bar to trigger the twx macros, none of them are assigned to keys. the result is that all of them say SHIFT 0 instead of the key button like 'A', 'B', 'C', ect... Any idea how to set it to read the button instead of the keys?

Maverick

Author:  Promethius [ Tue Sep 05, 2006 11:02 pm ]
Post subject: 

quote:Originally posted by Maverick2002

Works great. I use the button bar to trigger the twx macros, none of them are assigned to keys. the result is that all of them say SHIFT 0 instead of the key button like 'A', 'B', 'C', ect... Any idea how to set it to read the button instead of the keys?

Maverick


I will setup a script later to key off of the button and see if I can find the codes for it. I don't have a list of the key codes and the ones in the script were obtained by basically entering a key and then looking at the config for the code.

Author:  Maverick2002 [ Tue Sep 05, 2006 11:12 pm ]
Post subject: 

You already have the keys listed it seems like 'A' = 65, etc. lol

And it works perfectly if I reassign each trigger to a set of keystrokes (ie 'Ctrl + A' or 'Shft + B')

Maverick

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/