Creating an lprog
You can currently set the lprog
on the following types of things:
- Mob prototypes
- Object prototypes
- Rooms
- Ship templates
Note that mobs/objects/rooms don't need to be flagged as prototypes, but for mobs/objects, the lprog always lives with the vnum itself instead of any specific instance of the mob/object vnum.
Inside an lprog
, you can always use self
as the entity the lprog belongs to. To see what you can do with that self
variable, see the char_proto, obj_proto, ship_template, and room modules from the sidebar.
The body of an lprog
should be primarily trigger registration. For example, where you might previously do mpedit nerf add death 100
, you would now do mset nerf lprog
and add the following code to the buffer:
self:onDeath(function(self, killer) -- Do something end)
You would add any other triggers into the same lprog body rather than setting new lprogs since, for now, any entity can only have a single lprog.
Once set, the lprog applies to all current and future instances of the entity. In the above example, all nerfs would now have that onDeath behavior.
Debugging
As long as you have access to the log channel, you can add lines like LOTJ.log("some text")
to your program. This can be helpful if your program is partially executing. Any execution errors would also be sent to the log channel, usually with a line number where the problem happened.