Page 1 of 1

Spawning Monster with Connectors and/or Dropped Items?

Posted: Mon Jul 18, 2016 5:58 pm
by Mortis_of_Midian
How do I go about adding connectors (onDie) or Items to a monster spawned from a script?

Example spawn script line

spawn("uggardian", 4, 15, 26, 1, 0)

Is there something I can add to the end of this? Eg: :addItem / addConnector:onDie ?

Sorry if this has been asked before, I've a had a good look around, but I can't find a clear answer.

Re: Spawning Monster with Connectors and/or Dropped Items?

Posted: Mon Jul 18, 2016 6:56 pm
by Isaac

Code: Select all

spawn("uggardian", 4, 15, 26, 1, 0).monster:addItem(spawn("dagger").item)
Adds a dagger to the spawned Uggardian.

Re: Spawning Monster with Connectors and/or Dropped Items?

Posted: Mon Jul 18, 2016 6:57 pm
by Zo Kath Ra
Spawns the uggardian at the script entity's location and adds a connector for onDie:

Code: Select all

local ugga = spawn("uggardian", self.go.level, self.go.x, self.go.y, self.go.facing, self.go.elevation)
ugga.monster:addConnector("onDie", self.go.id, "uggaDies")

function uggaDies()
	hudPrint("Dead")
end

Re: Spawning Monster with Connectors and/or Dropped Items?

Posted: Tue Jul 19, 2016 1:14 pm
by Mortis_of_Midian
Thanks again guys - I had a brief chance to try it out this morning, all working perfectly :-)