Ask a simple question, get a simple answer
Re: Ask a simple question, get a simple answer
Aha: problem.
A delayedCall command runs to the end, you can't pause it, right?
Well, my candle runs out of "wax" when it it lit. Means: when carried in a champions attack hand. If I start a delayedCall as soon as a champion holds the candle in hand it will vanish even the player removed it after 2 seconds. I think I have to use a timer anyway.
Create it on the fly and give it as its ID the ID of the candle item plus a suffix to make it different. This timer is running then only as long as a champion holds the candle. If not, it gets paused.
I see a few other problem coming but I will give it a try.
A delayedCall command runs to the end, you can't pause it, right?
Well, my candle runs out of "wax" when it it lit. Means: when carried in a champions attack hand. If I start a delayedCall as soon as a champion holds the candle in hand it will vanish even the player removed it after 2 seconds. I think I have to use a timer anyway.
Create it on the fly and give it as its ID the ID of the candle item plus a suffix to make it different. This timer is running then only as long as a champion holds the candle. If not, it gets paused.
I see a few other problem coming but I will give it a try.
Re: Ask a simple question, get a simple answer
I'd suggest adding a TimerComponent to the party on the fly instead of spawning a new object, so that you don't have the issue of the timer slowing down if the party leaves the map.
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.
Re: Ask a simple question, get a simple answer
I assume the compass is hardcoded? Or has anyone made their own compass that functions the same?
edit: Also how does the function work? I try this:
and is crashes the game saying it expects 'vec', but got 'number'.
edit: Also how does the
Code: Select all
LightComponent:setColor(color)
Code: Select all
light_component:setColor(50, 50, 25)
Grey Island mod(WIP): http://www.grimrock.net/forum/viewtopic ... 99#p123699
Re: Ask a simple question, get a simple answer
You need to pass vec(50, 50, 25) instead of just 50, 50, 25.
The compass is hardcoded, but it should be straightforward to re-implement: every frame, search the party's inventory for any compasses (the Head Hunter trait is a good example of searching party inventories) and use setGfxIndex() to set their icon according to the party's current facing. You could also look at script_entity_18 in the Twisted Passage level of Isle of Nex (here is a dungeon editor file that will load Isle of Nex) which handles the cursed compass.
The compass is hardcoded, but it should be straightforward to re-implement: every frame, search the party's inventory for any compasses (the Head Hunter trait is a good example of searching party inventories) and use setGfxIndex() to set their icon according to the party's current facing. You could also look at script_entity_18 in the Twisted Passage level of Isle of Nex (here is a dungeon editor file that will load Isle of Nex) which handles the cursed compass.
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.
Re: Ask a simple question, get a simple answer
Okay, some more questions.
I have an object from which on I have to create a monster and give it an onDie connector back to the former object (to a script component in it).
My problem: Since there could be more than one instance of the object (and then the monster) I cannot give them fixed IDs. So how to adress the monster and then back the object?
What I have tried is:
But that doesn't work. The target "scr" cannot be found. Also not scr (without quotes) or immediatly self.go.id or "self.go.id". So how to do this?
(The trick would also be needed for my candle item which is still not finished.)
I have an object from which on I have to create a monster and give it an onDie connector back to the former object (to a script component in it).
My problem: Since there could be more than one instance of the object (and then the monster) I cannot give them fixed IDs. So how to adress the monster and then back the object?
What I have tried is:
Code: Select all
onClick = function(self)
local tenta = spawn("tentacles", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation)
local scr = self.go.id
tenta.monster:addConnector("onDie", "scr" , "setRight")
end,
(The trick would also be needed for my candle item which is still not finished.)
- Zo Kath Ra
- Posts: 937
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: Ask a simple question, get a simple answer
You've made something like this?THOM wrote: ↑Sun Dec 06, 2020 10:22 am I have an object from which on I have to create a monster and give it an onDie connector back to the former object (to a script component in it).
My problem: Since there could be more than one instance of the object (and then the monster) I cannot give them fixed IDs. So how to adress the monster and then back the object?
Code: Select all
defineObject{
name = "wall_button_new",
components = {
{
class = "Model",
model = "assets/models/env/wall_button.fbx",
},
{
class = "Animation",
animations = {
press = "assets/animations/env/wall_button_press.fbx",
}
},
{
class = "Clickable",
offset = vec(0,1.375,0),
size = vec(0.25, 0.25, 0.25),
--debugDraw = true,
},
{
class = "Button",
sound = "button",
onActivate = function(self)
-- Spawn a monster one tile west of the button
local monster_entity = spawn("spore_mushroom", self.go.level, self.go.x - 1, self.go.y, self.go.facing, self.go.elevation)
monster_entity.monster:addConnector("onDie", self.go.id, "scriptOnDie")
end,
},
{
class = "Script",
},
{
class = "ScriptController",
name = "controller",
},
},
placement = "wall",
editorIcon = 12,
}
Code: Select all
function scriptOnDie(monster)
print("scriptOnDie", monster.go.name, monster.go.id)
end
When I press the button and then kill the monster, LoG2 prints "scriptOnDie spore_mushroom 653" in the console.
Re: Ask a simple question, get a simple answer
Is there some sort of delayed hudPrint function so all the lines don't show up at once? or do I just have to use timers?
Grey Island mod(WIP): http://www.grimrock.net/forum/viewtopic ... 99#p123699
- Zo Kath Ra
- Posts: 937
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: Ask a simple question, get a simple answer
self.go.id should work. Did you forget to put a ScriptControllerComponent named "controller" on the object?THOM wrote: ↑Sun Dec 06, 2020 10:22 am Okay, some more questions.
I have an object from which on I have to create a monster and give it an onDie connector back to the former object (to a script component in it).
My problem: Since there could be more than one instance of the object (and then the monster) I cannot give them fixed IDs. So how to adress the monster and then back the object?
What I have tried is:But that doesn't work. The target "scr" cannot be found. Also not scr (without quotes) or immediatly self.go.id or "self.go.id". So how to do this?Code: Select all
onClick = function(self) local tenta = spawn("tentacles", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation) local scr = self.go.id tenta.monster:addConnector("onDie", "scr" , "setRight") end,
(The trick would also be needed for my candle item which is still not finished.)
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.
Re: Ask a simple question, get a simple answer
Thanks, guys.
Got it.
The problem was not the adressing of the function but the function itself.
1. it had a misspelled command createComponent in it (the component to be created must be written in upper case e.g. "Socket")
2. there was also a problem in it with the self.go.id term - but I could solve this
Now it works.
Got it.
The problem was not the adressing of the function but the function itself.
1. it had a misspelled command createComponent in it (the component to be created must be written in upper case e.g. "Socket")
2. there was also a problem in it with the self.go.id term - but I could solve this
Now it works.