Page 1 of 1

On_fly not working like expected

Posted: Sat Apr 06, 2013 7:56 am
by Lord_BoNes
If I set the on_fly function variable (instead of declaring it directly, like the test dungeon does) then DSB crashes... it doesn't seem to be calling the function correctly (incorrect parameters)

Code: Select all

function crazy_axe_on_fly(id, x_curr, y_curr, tile_curr, face, flytimer)
	dsb_write({255,255,255}, "OBJECT "..id.." is at "..x.." , "..y.." (facing: "..face)
end

obj.crazy_axe = clone_arch(obj.axe, {
	name = "CRAZY AXE",
	on_fly = crazy_axe_on_fly,
} )
This code should work. But it crashes, telling me that the "id" variable is invalid :?

Re: On_fly not working like expected

Posted: Sat Apr 06, 2013 8:44 pm
by Sophia
Your parameter list is wrong. The first parameter of every on_ event is the archetype:

Code: Select all

function crazy_axe_on_fly(arch, id, x_curr, y_curr, tile_curr, face, flytimer)
   -- etc...
end