User:Sherry

From Flexible Survival
Revision as of 20:51, 18 May 2011 by Sherry (talk | contribs)
Jump to: navigation, search

triggers

Here's a sample trigger:

<trigger
   enabled="y"
   group="combat"
   match="^--< (ALLIES >|FOES >--)--------------------------------------------------------------$"
   omit_from_output="y"
   regexp="y"
   script="tocomb"
   sequence="100"
  >

This can be built in gui

  1. Check "Regular Expression" and "Omit from output"
  2. Filling in a group to tag the trigger and script of tocomb
  3. Using the trigger pattern

script portion

comb_win_name = "fs_comb"
local comb_win_failed = false

chat_win_name = "fs_chat"
local chat_win_failed = false


function initchat()
	chat_win = GetWorld (chat_win_name)
	local filename = GetInfo (67) .. chat_win_name .. ".mcl"
	Open (filename)
	chat_win = GetWorld (chat_win_name)
	if not chat_win then
		ColourNote ("white", "red", "Can't open chat world file: " .. filename)
		chat_win_failed = true  -- Give up trying to open
	end
end

	
function tochat (name, line, wildcards, styles)
	if not chat_win and not chat_win_failed then
		initchat()
	end
	if chat_win then
		for _, v in ipairs (styles) do
 		     chat_win:ColourTell (RGBColourToName (v.textcolour), RGBColourToName (v.backcolour), v.text) 
		end
		chat_win:Note("")
	end
end
 

function initcomb()
	comb_win = GetWorld (comb_win_name)
	local filename = GetInfo (67) .. comb_win_name .. ".mcl"
	Open (filename)
	comb_win = GetWorld (comb_win_name)
	if not comb_win then
		ColourNote ("white", "red", "Can't open combat world file: " .. filename)
		comb_win_failed = true  -- Give up trying to open
	end
end

	
function tocomb (name, line, wildcards, styles)
	if not comb_win and not comb_win_failed then
		initcomb()
	end
	if comb_win then
		for _, v in ipairs (styles) do
 		     comb_win:ColourTell (RGBColourToName (v.textcolour), RGBColourToName (v.backcolour), v.text) 
		end
		comb_win:Note("")
	end
end