If I understand the question, you want a function in a script entity to get called when you press a particular type of life crystal ?
One way of doing that would be to define your own life crystal, lets call it healing_crystal_poison and create an onClick function in that crystal that calls the function poisonwell inside the script poisonwell that is in the same place as the life crystal.
Code: Select all
defineObject{
name = "healing_crystal_poison",
components = {
{
class = "Model",
model = "assets/models/env/healing_crystal.fbx",
castShadow = false,
},
{
class = "Particle",
particleSystem = "crystal",
},
{
class = "Light",
offset = vec(0,1,0),
color = vec(39/255, 90/255, 205/255),
range = 7,
shadowMapSize = 128,
castShadow = true,
staticShadows = true,
},
{
class = "Sound",
offset = vec(0, 1.5, 0),
sound = "crystal_ambient",
},
{
class = "Animation",
animations = {
spin = "assets/animations/env/healing_crystal_spin.fbx",
},
},
{
class = "Clickable",
offset = vec(0, 1.5, 0),
size = vec(1.6, 2, 1.6),
maxDistance = 1,
onClick = function(self)
local x,y = 0,0
for e in self.go.map:entitiesAt(self.go.x, self.go.y) do
if e.script and e.script.poisonwell then
e.script:poisonwell()
end
end
end,
},
{
class = "Obstacle",
},
{
class = "ProjectileCollider",
},
{
class = "Crystal",
cooldown = 120,
},
},
placement = "floor",
editorIcon = 60,
automapIcon = 104,
automapIconLayer = 1,
}
So place this crystal in your map, create a script called poisonwell and place it on top of your crystal, then create a function within that script called poisonwell.
When you use that crystal anything inside the poisonwell function will get executed.
Hope that helps.
Skuggasveinn.