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
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
Thanks. I assume that this would work for any item placed in an alcove as long as you give it the item name.
Here is a revised version that checks the object class type. LoG1 objects only have one class; unlike LoG2 objects... so it makes more sense in LoG1 to check the class type instead of the arbitrary object name. Now it works with altars as well.
function destroySpecialPotion(self) --self is the object that called; in this case it is the alcove object.
local alcove = self --relabled 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.
if type(alcove) == "table" then
if alcove.class == "Alcove" or alcove.class == "Altar" then --tests that calling object is of proper object class.
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 ther 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 height = {Alcove = 1.3, Altar = 1.1}
local effect = spawn("fx",itm.level,itm.x,itm.y,itm.facing) --spawns fx object at the itm object's location.
effect:translate(0,height[alcove.class],0) --raises the fx objects position to match 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.
return
end
end
end
end
end
*Re-revised to improve the blob effect's position for alcoves; now offset differently for each faced direction.
Last edited by Isaac on Mon May 10, 2021 2:27 pm, edited 6 times in total.
Here is a revised version that checks the object class type. LoG1 objects only have one class; unlike LoG2 objects... so it makes more sense in LoG1 to check the class type instead of the arbitrary object name. Now it works with altars as well.
function destroySpecialPotion(self) --self is the object that called; in this case it is the alcove object.
local alcove = self --relabled 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.
if type(alcove) == "table" then
if alcove.class == "Alcove" or alcove.class == "Altar" then --tests that calling object is of proper object class.
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 ther 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 objects position to match 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
end
Got it. Well, this thing is slowly coming along. Calling it a night. More tomorrow.
Isaac wrote: ↑Mon May 10, 2021 3:22 am
Here is a revised version that checks the object class type. LoG1 objects only have one class; unlike LoG2 objects... so it makes more sense in LoG1 to check the class type instead of the arbitrary object name. Now it works with altars as well.
I'd add a return statement after itm:destroy()
It's not necessary to continue iteration, and I don't think you're supposed to, because you've modified the list of contained items.
Isaac wrote: ↑Mon May 10, 2021 3:22 am
Here is a revised version that checks the object class type. LoG1 objects only have one class; unlike LoG2 objects... so it makes more sense in LoG1 to check the class type instead of the arbitrary object name. Now it works with altars as well.
I'd add a return statement after itm:destroy()
It's not necessary to continue iteration, and I don't think you're supposed to, because you've modified the list of contained items.
That's actually a very good point. You know, before I retired (yes, I'm old LOL) I used to be a programmer for a medical billing software company. I was quite good. But it's been a long time and I'm rusty. But the bigger problem is learning a new language when there isn't a full blown textbook to study. My C++ book was over 1,000 pages. The scripting for LoG seems to be very bare bones as far as reference materials. That's what's making this so difficult for me. Logic I know inside and out. But when you don't know what the commands are or what arguments they require, it makes coding a royal PITA. In short, it's like learning how to walk all over again. Challenging, but frustrating too.
wagtunes wrote: ↑Mon May 10, 2021 2:27 pmBut when you don't know what the commands are or what arguments they require, it makes coding a royal PITA.
LoG2 scripting is better documented, and more powerful. The principle difference is that object class has become modular with components; each one having its own class. An LoG2 object can have multiple components that affect its behavior and features. LoG2 components can even be added, or removed at runtime.
Also they usually have getter/setter functions that allow checking, and changing internal values; things that for LoG1 would require custom object definitions for each variation.
wagtunes wrote: ↑Mon May 10, 2021 2:27 pmBut when you don't know what the commands are or what arguments they require, it makes coding a royal PITA.
LoG2 scripting is better documented, and more powerful. The principle difference is that object class has become modular with components; each one having its own class. An LoG2 object can have multiple components that affect its behavior and features. LoG2 components can even be added, or removed at runtime.
Also they usually have getter/setter functions that allow checking, and changing internal values; things that for LoG1 would require custom object definitions for each variation.
And with all that, believe it or not, from a player perspective, I like LoG 1 better. It has that classic 1980s look that I first discovered with Eye Of The Beholder. Especially EotB II.
I like LoG1 better, but prefer LoG2 scripting. The LoG2 engine can be used to make LoG1 style adventures.
*Though Petri has asked that no one remake LoG1 with it.
ORRR2 could be ported to LoG2, and the scripting able to be greatly simplified to achieve the same result, as well as having the potential for more complex behavior.