Help with scripting (aliases/functions)

Post Reply
Dhaed
Posts: 12
Joined: Wed Feb 03, 2010 3:55 pm

Help with scripting (aliases/functions)

Post by Dhaed »

So I'm setting up lookup tables for my cures, and I'm running into a problem where my affliction can have more than one cure. So the following is my lookup table and my affliction being passed to the the function that calls for the cure

Code: Select all

function cureAffs_pipe(aff)
	send(pipeTable[aff])
end

pipeTable = {}
	pipeTable.aeon = "smoke elm"
	pipeTable.deadening = "smoke elm"
	pipeTable.hellsight = "smoke elm"
	pipeTable.madness = "smoke elm"
	pipeTable.disloyalty = "smoke valerian"
	pipeTable.manaleech = "smoke valerian"
	pipeTable.slickness = "cureSlickness"

cureAffs_pipe("slickness")
What I also have is an alias with the following
Pattern:

Code: Select all

^cureSlickness$
Value:

Code: Select all

if hellspawn.asthma == true and hellspawn.herb_balance == true then
	cureAffs_herb("bloodroot")
end
What's happening is that when 'cureSlickness' is being sent to the mud, the alias pattern isn't firing and expanding the alias. I know I could do the following to accomplish my goal, but it doesn't lend itself to a neat and tidy lookup table.

Code: Select all

function cureAffs_pipe(aff)
	if aff == "slickness" then
		expandAlias("cureSlickness")
	else
		send(pipeTable[aff])
	end
end

pipeTable = {}
	pipeTable.aeon = "smoke elm"
	pipeTable.deadening = "smoke elm"
	pipeTable.hellsight = "smoke elm"
	pipeTable.madness = "smoke elm"
	pipeTable.disloyalty = "smoke valerian"
	pipeTable.manaleech = "smoke valerian"
	pipeTable.slickness = "cureSlickness"

cureAffs_pipe("slickness")
For example the next lookup table is comprised of nearly all aliases.

Code: Select all

function cureAffs_salve(aff)
	if hellspawn.salve_balance = true then
		send(salveTable[aff])
	end
end

salveTable = {}
    salveTable.leftleg_broken = "Mending left leg"
    salveTable.rightleg_broken = "Mending right leg"
    salveTable.leftarm_broken = "Mending left arm"
    salveTable.rightarm_broken = "Mending right arm"
    salveTable.leftleg_damaged = "Restoration left leg"
    salveTable.rightleg_damaged = "Restoration right leg"
    salveTable.leftarm_damaged = "Restoration left arm"
    salveTable.rightarm_damaged = "Restoration right arm"
    salveTable.head_damaged = "Restoration head"
    salveTable.torso_damaged = "Restoration torso"
    salveTable.stuttering = "apply epidermal"
    salveTable.selarnia = "Mending"
    salveTable.anorexia = "apply epidermal"
    salveTable.ablaze = "Mending"
    salveTable.chilled = "apply caloric"
How can I get my aliases to expand from within the lookup table?

naftali
Posts: 138
Joined: Wed Jan 20, 2010 8:42 pm

Re: Help with scripting (aliases/functions)

Post by naftali »

You're looking for the expandAlias() function, as described in the mudlet manual. There are better ways of doing this though, mostly involving functions and not aliases

Post Reply