DSB Object Event Handlers (on_*)

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
ian_scho
High Lord
Posts: 2806
Joined: Fri Apr 07, 2006 8:30 am
Location: Zaragoza, Spain

DSB Object Event Handlers (on_*)

Post by ian_scho »

If you're trying to get a handle on events fired off objects in a dungeon. This is the list for you:

Items

on_throw(id, location)
See methods.lua, function method_throw_obj

on_impact
A Ven Bomb uses this, so an example function would be poisonbomb_thing(self, id, hit_what, hit_ppos)

on_deplete(id)
Call dsb_delete(id) if this event doesn't exist for the object. Assign a convert_deplete property for an arch type.

on_click(self, id, clicked_with, cx, cy)
Used on a mirror, or a compass. The cx and cy values are the exact coordinates (relative to the upper left corner of the object's bitmap) that you clicked on, making it possible to define custom "click zones" with a bit of hacking.

on_look(self, id, whose_eye) = new_id
This is called when you click on someone's eye with an inst. If it returns an id, that id is shown, instead of the one actually held to the eye.

on_drop(self, id)
Called when an inst is dropped. If it returns true, the inst can't be dropped.

on_zone_drop(self, drop_zone_id, dropped_obj_id)
Called when an inst is dropped into a drop zone (i.e., an alcove). If it returns true, the alcove won't accept the inst.

on_trigger(self, id, trigger_id)
Called when something is put on a flooritem. (If trigger_id is nil, it's the party)

off_trigger(self, id, trigger_id)
Called when something comes off a flooritem. (If trigger_id is nil, it's the party)

on_turn(self, id, dir)
Useful for the compass, for example.

on_fly(id, x, y, tile, face, flytimer)
Used in the test_dungeon, see crazy axe.

on_consume
See function eatdrink, where you need to set a foodval or waterval property for the arch type.

on_spawn
Fired when created, such as a monster death cloud of dust.

Also for the inventory there are events such as to_feet(id, who), from_feet(id, who), to_neck(id, who), from_neck(id, who), to_r_hand, from_r_hand, to_l_hand, from_l_hand and I just found after_from_r_hand and after_from_l_hand which pleases me greatly... Where I've finally found a to_anywhere and from_anywhere event.

Not an 'event' as such but we also have flying_away, flying_toward, flying_side properties to assign if necessary for a bitmap.

potion_effect(id, who, base_power)
Create your own potions and effects.

hit_sound
Used for weapons, assigning a sound.

namechanger(id, who_look)
Used with the bones object or a Ven Bomb for example.

subrenderer(id)
Yeah, this is a good one... See the objects.lua

objzone_check(id, putting_in, zone)
See the objects.lua

Things such as stairs are objects of course and have events such as on_trigger, off_trigger, on_turn, on_try_move, ...

TODO: There are loads more referenced for monsters in monster.lua and monster_ai.lua.

TODO: Party specific handlers?

*** UNFINISHED *** UNFINISHED *** UNFINISHED *** UNFINISHED ***
PM me or add messages to this thread, and I'll update this post :wink:
User avatar
Parallax
DMwiki contributor
Posts: 424
Joined: Mon Aug 28, 2006 7:56 pm
Location: Back in New Jersey

Post by Parallax »

Thanks, this is a great starting point.
Post Reply