From Starbounder - Starbound Wiki
Jump to: navigation, search


These NPC hooks are stubs for global functions NPC scripts can define, which will be called by C++. Documentation for it was removed from the assets, but an old and outdated (2015) version can be found here: These functions are currently (2017 april) used in the /assets/npcs/bmain.lua script.



Called when the NPC is added to the world.


Update loop handler. Called once every `scriptDelta` (as defined in *.npctype) game ticks


Called after the NPC has taken damage.
'args' is a map of info about the damage, structured as:

sourceId = <entity id of entity that caused the damage>,
damage = <numeric amount of damage that was taken>,
sourceDamage = <numeric amount of damage that was originally dealt>,
sourceKind = <string kind of damage being applied, as defined in "damageKind" value in a *.projectile config>

Note that "sourceDamage" can be higher than "damage" if - for instance - some damage was blocked by a shield.


Called when the NPC is interacted with.
Available interaction responses are:


Now,"OpenMerchantInterface" and "ScriptPane" are effective.

'args' - Map of interaction event arguments:

     sourceId = <Entity id of the entity interacting with this NPC>
     sourcePosition = <The {x,y} position of the interacting entity>


  1. nil (no interaction response)
  2. string - the interaction response that should be performed
  3. array - the interaction response and configuration:
      <interaction response string>,
      <interaction response config table (map)>

Quick Navigation

Quick Navigation