Created
March 25, 2017 06:48
-
-
Save chosig/be3a0e7afd7179dd99fa44d7982d70d8 to your computer and use it in GitHub Desktop.
TinyFugue GMCP negotiation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; -*- folded-file: t -*- | |
; {{{ gmcp_handler | |
/def gmcp_handler = \ | |
/if (gmcp_debug) /echo % gmcp: %{*} %; /endif %;\ | |
/if ({1} !~ "Char.Vitals") \ | |
/echo % gmcp unrecognised %;\ | |
/return %;\ | |
/endif %;\ | |
/shift %;\ | |
/let s $[substr({*}, 1, -1)] %;\ | |
/while (strlen(s)) \ | |
/splitat , %{s} %;\ | |
/test s := {P2} %;\ | |
/splitat : %{P1} %;\ | |
/let var $[substr({P1}, 1, -1)] %;\ | |
/if (var =~ "hp") /set hpcur %P2 %; /endif %;\ | |
/if (var =~ "maxhp") /set hpmax %P2 %; /endif %;\ | |
/if (var =~ "gp") /set gpcur %P2 %; /endif %;\ | |
/if (var =~ "maxgp") /set gpmax %P2 %; /endif %;\ | |
/if (var =~ "xp") /set xpcur %P2 %; /endif %;\ | |
/if (var =~ "burden") /set burden %P2 %; /endif %;\ | |
/done %;\ | |
/status_redraw | |
; }}} | |
; {{{ /gmcp {0|off|1|on} | |
/def gmcp = \ | |
/if (!{#}) /echo gmcp=%{gmcp} %; /return %; /endif %;\ | |
/set gmcp %{*} %;\ | |
/if (gmcp) \ | |
/def -hGMCP gmcp_hook = /gmcp_handler %%{*} %;\ | |
/test gmcp("core.supports.set [ \\"Char.Vitals\\" ]") %;\ | |
/else \ | |
/undef gmcp_hook %;\ | |
/test gmcp("core.supports.set [ ]") %;\ | |
/endif | |
; }}} | |
/set gmcp_debug 1 | |
/gmcp on |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment