scripting help

Have trouble running Legend of Grimrock 2 or do you have questions about the purchasing options? Look for help here.
ratman
Posts: 72
Joined: Fri Jan 10, 2020 1:13 am

Re: scripting help

Post by ratman » Tue Jan 21, 2020 11:57 pm

I also tried in a new project and same warning

User avatar
Isaac
Posts: 2936
Joined: Fri Mar 02, 2012 10:02 pm

Re: scripting help

Post by Isaac » Wed Jan 22, 2020 12:34 am

That's very peculiar that I don't get an error with mine, but yours does.

Okay, try this variation on the script:

Code: Select all

altar_1.surface:addConnector('onAcceptItem', self.go.id, "itemSwap")
function itemSwap(surface, item)
	local checkItem = "rock"
	local itemReplacement = "figure_skeleton"
		if item.go.item:getStackSize() == 1 and
			item.go.name == checkItem then
			item.go:destroyDelayed()
			surface:addItem(spawn(itemReplacement).item)
			--optional effect 
			surface.go:createComponent('Particle'):setParticleSystem('beacon_crystal')
			surface.go.particle:setDestroySelf(true)
			surface.go.particle:fadeOut(1)
			surface.go:playSound('teleport')
			return false
		end
end
This one gives me no errors, but handles things slightly different than before; based on a hunch. The original script did have a bug—though it didn't crash for me. This version fixes that bug.

ratman
Posts: 72
Joined: Fri Jan 10, 2020 1:13 am

Re: scripting help

Post by ratman » Wed Jan 22, 2020 12:50 am

that works thank you. :D

billb52
Posts: 63
Joined: Sat Jul 05, 2014 3:08 pm

Re: scripting help

Post by billb52 » Tue Feb 18, 2020 5:17 pm

Hi Issac
Tried using your variation of the script but when you place the rock on the altar I end up with 2 'skeleton figurines' every time
and the particle system does not fade out, any ideas?

Post Reply