SpoilerShow
Code: Select all
function destroySpecialPotion(self) --self is the object that called; in this case it is the alcove object.
local alcove = self --relabeled self to alcove; just preference, self could be used directly.
potionName = "potion_rage" --"potionunlocking" --user defined potion name; no need to edit the IF block code to change names.
if type(alcove) == "table" and string.match(alcove.name,"alcove") then --tests that calling object is a table with "alcove" somewhere in its .name field.
for itm in alcove:containedItems() do --{The alcove's contained items iterator}
--An iterator returns then next object on its internal list when called.
--The FOR loop repeats until the end of the list, or until told to exit/return.
if itm.name == potionName then --compares name of the current itm (item/object); continues if it matches the potionName.
--optional effects
local effect = spawn("fx",itm.level,itm.x,itm.y,itm.facing) --spawns fx object at the itm object's location.
effect:translate(0,1.3,0) --raises the fx object's position to approximate height of the alcove shelf.
effect:setParticleSystem("blob") --sets the fx object's particle system to type "blob".
effect:setLight(0, 0, 1, 1000, 2, .5, true) --sets the fx object's light to a shade of blue. (R,G,B,...)
playSound("goromorg_shield_hit") --plays the sound used when the goromorg's shield is attacked.
--/optional effects
itm:destroy() --destroys the itm object; only when it is the named potion.
end
end
end
end