On_fly not working like expected

This forum is for the Lua scriptable clone of DM/CSB called Dungeon Strikes Back by Sophia. Use DSB to build your own highly customised games.

Moderator: Sophia

Forum rules
Please read the Forum rules and policies before posting.
Post Reply
User avatar
Lord_BoNes
Jack of all trades
Posts: 1064
Joined: Mon Dec 01, 2008 12:36 pm
Location: Ararat, Australia.

On_fly not working like expected

Post 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 :?
 
Image

1 death is a tragedy,
10,000,000 deaths is a statistic.
- Joseph Stalin

Check out my Return to Chaos dungeon launcher
And my Dungeon Master Clone
User avatar
Sophia
Concise and Honest
Posts: 4240
Joined: Thu Sep 12, 2002 9:50 pm
Location: Nowhere in particular
Contact:

Re: On_fly not working like expected

Post 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
Post Reply