Projects Random Reviews, Views and Commentary.

21Apr/14Off

Avatar MUD – MUSHclient – Spellup Checker

This MUSH script utility is my quick attempt at making a system to 'look over' your affects list and inform you if there are any spells missing after a spellup.

1. Open your script (.lua) file (if you have one) or create a new one. 

WARNING: watch for wrapped lines if you are copy/pasting the below.  It will break your script if they are line wrapped.

ADD (at top of file)

local spells = {"sanctuary", "frenzy", "infravision", "detect invis", "detect magic", "detect hidden", "detect evil", "barkskin", "giant strength", "stone skin", "shield", "fly", "pass door", "foci", "adrenaline pump", "anticipate", "biofeedback", "calcify flesh", "mental barrier", "body brace", "displacement", "energy shield", "fortitudes", "water breathing", "iron skin", "invincibility", "armor", "holy armor", "holy aura", "bless", "protection evil", "awen", "steel skeleton"}

local missingspells = {}
local scFire = 0

ADD (to very bottom of script file)

--[[ SPELL CHECKER FUNCTIONS --]]

function spellCheck()
	EnableTimer("SpellCheckTimer", true)
end

function spellCount(spell)
	--[[ Check SPELL against SpellList --]]
	local tmpspells = {}
	for i = 1, table.getn(missingspells) do
		if missingspells[i] == spell then
--[[			world.Note("## SPELL : Have" .. missingspells[i]) --]]
		else
			tmpspells[table.getn(tmpspells)+1] = missingspells[i]
		end
	end
	if spell == "heighten senses" then
		missingspells = tmpspells
		tmpspells = {}
		for i = 1, table.getn(missingspells) do
			if missingspells[i] == "detect hidden" or missingspells[i] == "detect invis" then
--[[				world.Note("## SPELL : Have" .. missingspells[i]) --]]
			else
				tmpspells[table.getn(tmpspells)+1] = missingspells[i]
			end
		end
	end
	missingspells = tmpspells
end

function spellResult()
	local missing = 0
	if scFire == 0 then
		EnableTrigger("SpellList", true)
		world.Send("aff")
		missingspells = spells
		scFire = scFire + 1
		world.Note("## SpellCheck Initiated - Please Stand By...")
		return
	end
	world.Note("## SpellCheck Output Results ... Missing Spells Listed Below:")
	EnableTrigger("SpellList", false)
	EnableTimer("SpellCheckTimer", false)
	for i = 1, table.getn(missingspells) do
		world.Note(i .. "> " .. missingspells[i])
		missing = missing + 1
	end
	if missing == 0 then
		world.Note(" > [NONE]")
	end
	scFire = 0
end

SAVE and CLOSE Script File

2. TIMER (Yep we use a timer for this) - Change to Timers

ADD

Interval 5 seconds

Flags (none)

Label SpellCheckTimer

3. ALIASES

ADD

Alias spellcheck

Flags enabled

Send spellcheck()

SendTo Script

Group SpellChecker

4. TRIGGERS

ADD

Trigger: ^Spell: '(.*)' (.*)\.$

Flags: regular expression (NOT THIS IS NOT ENABLED)

Send: spellCount("%1")

SendTo: Script

Label: SpellList

5. Testing. Once complete you should be able to simply type spellcheck. If all went well, it should take about 10 seconds to evaluate your affects list and let you know what is missing.

Filed under: MUSH Comments Off
Comments (0) Trackbacks (0)

Sorry, the comment form is closed at this time.

Trackbacks are disabled.