Does onDie work in LOG 2?

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!
KnotuAgain
Posts: 17
Joined: Sun Oct 05, 2014 7:29 am

Does onDie work in LOG 2?

Post by KnotuAgain »

I want a monster to spawn some treasure when it dies.
I have:

onDie function(self)
spawn("bone_club", self.level, self.x, self.y, 0)
spawn("coin_copper", self.level, self.x, self.y, 0)
end

I tried it in the Lua script and in the a verision of the monster that I made. When I kill it, nothing happens, no treasure is dropped. I am pretty sure this is what I did in LOG 1.
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Does onDie work in LOG 2?

Post by msyblade »

You could just add the items to the monster in the dropdown box in the editor, then they will drop when it dies.
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
cameronC
Posts: 80
Joined: Wed Apr 11, 2012 10:54 pm

Re: Does onDie work in LOG 2?

Post by cameronC »

onDie should work but if you are just spawning items you can use monstername.monster:addItem() to give it to them and they will always drop it when they die.
Writer and sometimes artist of the very slightly acclaimed comic series Scrambled Circuits. A comic series about a robot written by a human.

Grimrock 2 socketSystem: viewtopic.php?f=22&t=8546 / Github
KnotuAgain
Posts: 17
Joined: Sun Oct 05, 2014 7:29 am

Re: Does onDie work in LOG 2?

Post by KnotuAgain »

I tried the monstername.monster:addItem()

ex.
my_mummy_A.monster:addItem("bone_club")

when in the monster script it gave the following error: "attempt to index global "my_mummy_A" ( a nil value).

When I tried it in the lua script that spawns the mummy, there was no error, but nothing dropped when I killed it.

Don't know what I am doing wrong, this should be simple. I had no problem doing it in LOG 1.
KnotuAgain
Posts: 17
Joined: Sun Oct 05, 2014 7:29 am

Re: Does onDie work in LOG 2?

Post by KnotuAgain »

I can't add the item in the drop down button, because it is spawns when the champions dig at a gravesite, therefore no drop down.
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Does onDie work in LOG 2?

Post by NutJob »

addItem accepts an object not a string.
KnotuAgain
Posts: 17
Joined: Sun Oct 05, 2014 7:29 am

Re: Does onDie work in LOG 2?

Post by KnotuAgain »

Weird. I tried no " "'s
No error when I put in the monster script, but no drop either.

Tried in the lua script and I get the error that I had earlier in the Monster file.
attempt to index "my_mummy_A" ( a nil value).

I am at a lost.
KnotuAgain
Posts: 17
Joined: Sun Oct 05, 2014 7:29 am

Re: Does onDie work in LOG 2?

Post by KnotuAgain »

I would not have to create my own verision of a monster if I could get it to not drop what it normally drops and switch it with what I want it to drop.

has anyone one gotten the onDie to work?
NutJob
Posts: 426
Joined: Sun Oct 19, 2014 6:35 pm

Re: Does onDie work in LOG 2?

Post by NutJob »

yes attach that event to the party object with addConnector or use defineObject in the objects.lua
KnotuAgain
Posts: 17
Joined: Sun Oct 05, 2014 7:29 am

Re: Does onDie work in LOG 2?

Post by KnotuAgain »

I GIVE UP !
LOG 1 was easy to mod. LOG 2 I can't even get a dumb monster to drop an item. Why did they make everything so hard this time around. I tried to make a mine level and the ceiling is all screwed up. I can't get the beach to have an ocean. I have been working on this for 3 days and have nothing to show for it. It is like going from first grade to college in one step. Nothing works.
Post Reply