Getting the ID of toches and other spawned items?
Getting the ID of toches and other spawned items?
If I wanted to, say, destroy a torch holder and the torch inside it, how would I got about referring to the torch. I made an alcove that prints the id of the item placed in it, and torches spawned with the holder have a different one each time the game is loaded.
Re: Getting the ID of toches and other spawned items?
Not sure if this works, but can you use entitiesAt(lvl,x,y) to get the id of the torch in the holder in square x,y
If you don't know the x,y but you know the name of the torch holder, you can get it's x,y first and then use entitiesAt() to get the name of the torch there.
ok a very basic script which I just tested (set to test level 1 square (15,14)):
prints to the hud the name and id of all items in that square. in my case it returned torch_holder_1 and torch 2032
you could then process an IF statement based on the name that calls a destroy
If you don't know the x,y but you know the name of the torch holder, you can get it's x,y first and then use entitiesAt() to get the name of the torch there.
ok a very basic script which I just tested (set to test level 1 square (15,14)):
Code: Select all
function findEntityNames()
for i in entitiesAt(1,15,14) do
hudPrint(i.name .. " with id = " .. i.id)
end
end
you could then process an IF statement based on the name that calls a destroy
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Re: Getting the ID of toches and other spawned items?
OK... this little script tests the names of objects in a square and if they begin with the word torch they are destroyed...
you could make the script more generic by passing variables for level, x and y to it.. so you could call destroyTorches(lvl,x,y)
Code: Select all
function destroyTorches()
for i in entitiesAt(1,15,14) do
-- hudPrint(i.name .. " with id = " .. i.id)
if i.name:sub(1,5) == "torch"
then
i:destroy()
end
end
end
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Re: Getting the ID of toches and other spawned items?
Thanks, that seems to do it.
Re: Getting the ID of toches and other spawned items?
Hmm, spawned torches don't seem to have any sound effect, and I wanted to use torches to get the burning sound since couldn't figure out how to make a playSound start and stop.
Re: Getting the ID of toches and other spawned items?
I'm trying to make a similar script for an enchanted item that damages nearby skeletons, what is it exactly that
does?
Code: Select all
i.name:sub(1,5)
Re: Getting the ID of toches and other spawned items?
i.name is the name of an item from the the loop.. in that case one of the entitiesLmaoboat wrote:I'm trying to make a similar script for an enchanted item that damages nearby skeletons, what is it exactly thatdoes?Code: Select all
i.name:sub(1,5)
sub(1,5) means take a substring of the name starting at the character 1 and being 5 characters in length...
so if i.name = "torch_holder"
then i.name:sub(1,5) = "torch"
edit.. in the previous script it was basically a shortcut for selecting any of the following "torch" "torch_holder" and "torch_everburning"
Puzzle Frameworks - http://www.grimrock.net/forum/viewtopic.php?f=14&t=4564
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382
Magic Pack - https://www.nexusmods.com/grimrock/mods/70
Area of Effect Spell System - http://www.grimrock.net/forum/viewtopic ... 150#p44382