What I'm trying to do is create a stand-in for a poison fountain. What I would like to do is attach a poisoning script to the activation of chosen instances of life crystals.
Unfortunately, I can't seem to find how to add a scripting component to the life crystal.
Tieing a script to the activation of an object
- Skuggasveinn
- Posts: 562
- Joined: Wed Sep 26, 2012 5:28 pm
Re: Tieing a script to the activation of an object
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.
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.
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,
}When you use that crystal anything inside the poisonwell function will get executed.
Hope that helps.
Skuggasveinn.
Last edited by Skuggasveinn on Sun Sep 27, 2015 9:03 pm, edited 1 time in total.
Re: Tieing a script to the activation of an object
You'll want to change that so that it only executes that block if the crystal is actually active, surely - clicking on the dead crystal shouldn't do anything.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.