python.tin
- change to
python3
or justpython
depending on your setup
- python.tin
#run {python} {python3 -B} from pyLib.tintin import TinTin #read scripts/scripting.tin #read scripts/utils.tin #gts
- scripting.tin
#action {^tintin_execute (%1) %2$} { #%1 %2 } #action {^tintin_ticker (%1) (%2) (%3) (%4)$} { #%1 #ticker {%2} {%3} {%4} } #action {^tintin_delay (%1) (%2) (%3) (%4)$} { #%1 #delay {%2} {%3} {%4} } #action {^tintin_var (%1) (%2) (%3)$} { #%1 #var {%2} {%3} } #action {^tintin_send (%1) %2$} { #%1 #send {%2} } #action {^tintin_showme (%1) %2$} { #%1 #showme {%2} } #action {^tintin_echo (%1) (%2) (%3) (%4) (%5) (%6) (%7) (%8) (%9) (%10) (%11) (%12) (%13) (%14) (%15) (%16) (%17) (%18) (%19) (%20) (%21)$} { #%1 #echo {%2} {%3} {%4} {%5} {%6} {%7} {%8} {%9} {%10} {%11} {%12} {%13} {%14} {%15} {%16} {%17} {%18} {%19} {%20} {%21} }
- utils.tin
#function {math} { #math {result} {%0} } #function {strip} { #format {result} {%p} {%0} } #function {len} { #format {result} {%L} {%0} } #function {ord} { #format {result} {%A} {%0} } #function {upper} { #format {result} {%u} {%0} } #function {wrap} { #format {result} {%w} {%0} } #function {capitalize} { #format {result} {%n} {%0} } #function {epoch} { #format {result} {%T} } #function {reverse} { #format {result} {%r} {%0} } #function {lower} { #format {result} {%l} {%0} } #function {chr} { #format {result} {%a} {%0} } #function {int} { #format {result} {%d} {%0} } #function {float} { #format {result} {%f} {%0} } #function {isdigit} { #if {"@int{%0}" == "%0"} {#return {1}}; #else {#return {0}} } #function {abs} { #if {%0 < 0} {#math {result} {%0 * -1}}; #else {#return {%0}} } #function {beginning} { #format {result} {%.%2s} {%1} } #function {ending} { #var {result} {@reverse{@beginning{{@reverse{%1}}{%2}}}} } #function {startswith} { #if {"@beginning{{%1}{@len{%2}}}" == "%2"} {#return {1}}; #else {#return {0}} } #function {endswith} { #if {"@ending{{%1}{@len{%2}}}" == "%2"} {#return {1}}; #else {#return {0}} } #function {isin} { #regexp {%1} {%2} {#return {1}}{#return {0}} } #function {slice} { #regexp {%1} {^{.{@math{@int{%2}-1}}}{.{@math{(@int{%3}-@int{%2}) + 1}}}} {#var {result} &2} {#var {result} {}} } #function {isvnum} { #map {get} {roomvnum} {tmpIsVnum} {@int{%0}}; #if {($tmpIsVnum) && ("$tmpIsVnum" == "%0")} { #var {result} {1} }; #else { #var {result} {0} }; #unvar {tmpIsVnum} } #function {maplist} { #var {result} {}; #switch {"%1"} { #case {"name"} {#map {list} {variable} {result} {%2}}; #case {"exits"} {#map {list} {variable} {result} {} {%2}}; #case {"desc"} {#map {list} {variable} {result} {} {} {%2}}; #case {"area"} {#map {list} {variable} {result} {} {} {} {%2}}; #case {"note"} {#map {list} {variable} {result} {} {} {} {} {%2}}; #case {"terrain"} {#map {list} {variable} {result} {} {} {} {} {} {%2}}; #case {"flags"} {#map {list} {variable} {result} {} {} {} {} {} {} {%2}} } } #function {format} { #format {result} {%1} {%2} {%3} {%4} {%5} {%6} {%7} {%8} {%9} {%10} {%11} {%12} {%13} {%14} {%15} {%16} {%17} {%18} {%19} {%20} {%21} } #function {listToSet} { #forall {$%0[%*]} { #var {tmpResult[&0]} {true} }; #var {result} {$tmpResult}; #unvar {tmpResult} } #var {reverseDirections} {} #var {reverseDirections[north]} {south} #var {reverseDirections[south]} {north} #var {reverseDirections[east]} {west} #var {reverseDirections[west]} {east} #var {reverseDirections[up]} {down} #var {reverseDirections[down]} {up}