The object spawn code could include a check for the ID it's about to use; to avoid potential ID collisions with other objects. The ID string itself could also be made rather complex, to further reduce the chance of a another script with that same ID existing in a mod that has included it. While both of these might be overly cautious, the spawn function can currently crash the game [for duplicate entity] if there is already an object on the map with the same name.zimberzimber wrote:Code: Select all
onInit = function(self) spawn("script_entity", 1, 0, 0, 0, 0, "id_for_this_object_for_future_reference").script:loadFile("mod_assets/external_scripts/my_external_script.lua") self.go:destroy() end
Ask a simple question, get a simple answer
Re: Ask a simple question, get a simple answer
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
Right, forgot to include it...Isaac wrote:The object spawn code could include a check for the ID it's about to use; to avoid potential ID collisions with other objects. The ID string itself could also be made rather complex, to further reduce the chance of a another script with that same ID existing in a mod that has included it. While both of these might be overly cautious, the spawn function can currently crash the game [for duplicate entity] if there is already a script on the map with the same name.
Worst of all, forgot to include it in my asset pack
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
-
- Posts: 16
- Joined: Wed Jan 11, 2017 9:46 pm
Re: Ask a simple question, get a simple answer
Hello, another quick question.
Consumable items when in hands are used via attack action which triggers the onAttackHook.
So as long as I can identify the item, I can work with it and see if the character is eating or using a potion.
But when the item is consumed in the inventory it does not trigger the onAttackHook and I am not seeing it trigger any hook.
Is there any hook that it triggers?
Consumable items when in hands are used via attack action which triggers the onAttackHook.
So as long as I can identify the item, I can work with it and see if the character is eating or using a potion.
But when the item is consumed in the inventory it does not trigger the onAttackHook and I am not seeing it trigger any hook.
Is there any hook that it triggers?
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Ask a simple question, get a simple answer
The UsableItem component has an onUseItem hook that receives (self, champion).PedroMoniz wrote:Hello, another quick question.
Consumable items when in hands are used via attack action which triggers the onAttackHook.
So as long as I can identify the item, I can work with it and see if the character is eating or using a potion.
But when the item is consumed in the inventory it does not trigger the onAttackHook and I am not seeing it trigger any hook.
Is there any hook that it triggers?
This hook is also called when the item is consumed from the hero panel.
Bonus: If you return false, the item will not be consumed
Here's an example:
Code: Select all
class = "UsableItem",
onUseItem = function(self, champion)
playSound("consume_potion")
hudPrint("The flask is full of water again!")
return false
end,
My asset pack [v1.10]
Features a bit of everything!
Features a bit of everything!
-
- Posts: 16
- Joined: Wed Jan 11, 2017 9:46 pm
Re: Ask a simple question, get a simple answer
Thank you,
did not see there are a usable item component.
did not see there are a usable item component.
Re: Ask a simple question, get a simple answer
There is also a second [more up to date] scripting reference for Grimrock 2.PedroMoniz wrote:Thank you,
did not see there are a usable item component.
https://github.com/JKos/log2doc/wiki
- Zo Kath Ra
- Posts: 937
- Joined: Sat Apr 21, 2012 9:57 am
- Location: Germany
Re: Ask a simple question, get a simple answer
When a monster dies, it explodes in a shower of sparks.
I want a forest_old_oak to explode like this.
Other than making a monster that looks just like a forest_old_oak, is there a way to do this?
I want a forest_old_oak to explode like this.
Other than making a monster that looks just like a forest_old_oak, is there a way to do this?
Re: Ask a simple question, get a simple answer
Code: Select all
do
local p = forest_old_oak_1:spawn("particle_system")
p.particle:setParticleSystem("death")
p.particle:setEmitterMesh(forest_old_oak_1.model:getModel())
local l = p:createComponent("Light")
l:setRange(4)
l:setColor(vec(0.6078431372549,0.4,0.27058823529412))
l:setOffset(vec(0,1.5,0))
l:setBrightness(40)
l:setFadeOut(1)
forest_old_oak_1:destroy()
end
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
Yes, but it has to have the sound effects too!
Updated.
Updated.
Last edited by Isaac on Tue Jan 31, 2017 4:58 am, edited 1 time in total.
Re: Ask a simple question, get a simple answer
I have a rough idea of how sequencing is used to open up pits or activate spikes in a specific order with timers or counters, but what about player activated objects like buttons? Can the same sort of code be used to press buttons in a specific order or is it a little more convoluted than that? I know I could achieve the same results with levers or pressure_plates with potentially less hassle but I don't want to overuse either in my mod.