Difference between revisions of "DSB/Events and System Functions"

From DmWiki
Jump to navigationJump to search
(New page: == System Functions == When certain things happen globally, or values are needed, the game engine will call <b>sys_</b> functions. <small> All of them are contained in <i>base/system.lua<...)
 
Line 72: Line 72:
  
  
[[Category:DSB]]
+
[[Category:DSB|Events and System Functions]]

Revision as of 19:21, 16 August 2008

System Functions

When certain things happen globally, or values are needed, the game engine will call sys_ functions.

All of them are contained in base/system.lua (except for the rendering-related ones, in base/render.lua), so look there for now. If anyone wants to wiki-ize the list, feel free. I'll be working mostly on things that I haven't documented somewhere else. -- Sophia

Events

When certain things happen to a specific object, the game engine (or, sometimes, the Base Code) will call various events associated with an object arch.

on_throw(self, id, location)
The location is where the object is thrown "from," via an attack method. It is nil if the object is thrown from the mouse hand. In that case, if you need to assume the throw came from some inventory zone, you can use the global variable mousethrowinghand.
See also base/methods.lua: methodthrowobj.
onimpact(self, id, hitwhat, hitppos, hitparty)
This function is called when an inst hits something. If it hits a monster or object, hitwhat will be set to an inst id. If it hits a party member, hitwhat will be nil, hitppos will be the party position that it hit, and hitparty will be the party that was hit (which can be ignored in most cases)
See also base/damage.lua: explodething, poisonbombthing, etc.
on_deplete(self, id)
When an inst with charges consumes its last charge, this event is called. If this event doesn't exist, but the arch has a convertdeplete property, a dsbswap is executed. Otherwise, the object is deleted.
onclick(self, id, clickedwith, 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.
onlook(self, id, whoseeye) = 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.
onzonedrop(self, dropzoneid, droppedobjid)
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.
ontrigger(self, id, triggerid)
Called when something is put on a flooritem. (If trigger_id is nil, it's the party)
offtrigger(self, id, triggerid)
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 testdungeon_, 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 tofeet(id, who), fromfeet(id, who), toneck(id, who), fromneck(id, who), torhand, fromrhand, tolhand, fromlhand and I just found afterfromrhand and afterfromlhand which pleases me greatly... Where I've finally found a toanywhere and fromanywhere event.

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

potioneffect(id, who, basepower)
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
objzonecheck(id, puttingin, zone)
See the objects.lua

Things such as stairs are objects of course and have events such as ontrigger, offtrigger, onturn, ontry_move, ...