Custom Potion & Destroying a spawned item

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
Post Reply
Emera Nova
Posts: 146
Joined: Wed Jun 11, 2014 1:31 am

Custom Potion & Destroying a spawned item

Post by Emera Nova »

So I'm attempting to destroy something I just spawned in, (its for visual effects) and I keep trying to guess what the items name is.
SpoilerShow
function destroyObject()
if findEntity("tomb_wall_sarcophagus_mummy_5") ~= nil then
tomb_wall_sarcophagus_mummy_5:destroy()
end
end
Above is the code I currently have in the one script, the tomb_wall object is what I've spawned in but I don't know for a fact that that name is what it goes by. Is there any way to figure out what the name of a spawned in item is? At the moment I have a pressure plate that when stepped on destroys whats already in place and then spawns in the tomb_wall_sarcophagus_mummy. I already have 4 others of it in the dungeon so I assumed that putting _5 after it would be what its called but my script isn't deleteing it.

Second thing I'm attempting to work on is making a potion that the party could make that basically only heals either wounds, I plan on just using the normal red potion model for it and picture for in game just with a different text on it.

As far as coding a new potion in and the recipe for it how would I go about doing that. I know theres a spell someone made to make it so you can cast and heal your parties wounds that way, but I'm attempting to find a way to just have an item that you can have do that and I think the potions would be the fun way to have that be in there.
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Custom Potion & Destroying a spawned item

Post by minmay »

Emera Nova wrote:So I'm attempting to destroy something I just spawned in, (its for visual effects) and I keep trying to guess what the items name is.
SpoilerShow
function destroyObject()
if findEntity("tomb_wall_sarcophagus_mummy_5") ~= nil then
tomb_wall_sarcophagus_mummy_5:destroy()
end
end
Above is the code I currently have in the one script, the tomb_wall object is what I've spawned in but I don't know for a fact that that name is what it goes by. Is there any way to figure out what the name of a spawned in item is? At the moment I have a pressure plate that when stepped on destroys whats already in place and then spawns in the tomb_wall_sarcophagus_mummy. I already have 4 others of it in the dungeon so I assumed that putting _5 after it would be what its called but my script isn't deleteing it.
There are 2 very easy ways to do this.
1. spawn() returns the spawned object. So you can simply do

Code: Select all

sarcophagusId = spawn("tomb_wall_sarcophagus_mummy").id

...

function destroyObject()
   if findEntity(sarcophagusId) then
   findEntity(sarcophagusId):destroy()
	end
end
2. spawn()'s last argument is an id to give the object. So if you use

Code: Select all

spawn("tomb_wall_sarcophagus_mummy",level,x,y,facing,elevation,"tomb_wall_sarcophagus_mummy_5")
the sarcophagus is guaranteed to have the id "tomb_wall_sarcophagus_mummy_5" (unless an object with that name already exists in which case the game will crash).
Emera Nova wrote:Second thing I'm attempting to work on is making a potion that the party could make that basically only heals either wounds, I plan on just using the normal red potion model for it and picture for in game just with a different text on it.

As far as coding a new potion in and the recipe for it how would I go about doing that. I know theres a spell someone made to make it so you can cast and heal your parties wounds that way, but I'm attempting to find a way to just have an item that you can have do that and I think the potions would be the fun way to have that be in there.
Very simple to do; look at the asset pack when it comes back online.
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.
Post Reply