Advertisement
Guest User

Starbound Glad Giraffe 1 (2015-12-08) npchooks.lua API

a guest
Apr 28th, 2017
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.84 KB | None | 0 0
  1. --- Stubs for global functions NPC scripts can define, which will be called by C++
  2.  
  3. --- Called when the NPC is added to the world.
  4. function init() end
  5.  
  6. --- Update loop handler.
  7. -- Called once every `scriptDelta` (as defined in *.npctype) game ticks
  8. function update(dt) end
  9.  
  10. --- Called when the npc has died and is about to be removed.
  11. function die() end
  12.  
  13. --- Called after the NPC has taken damage.
  14. --
  15. -- @tab args Map of info about the damage, structured as:
  16. --    {
  17. --      sourceId = <entity id of entity that caused the damage>,
  18. --      damage = <numeric amount of damage that was taken>,
  19. --      sourceDamage = <numeric amount of damage that was originally dealt>,
  20. --      sourceKind = <string kind of damage being applied, as defined in "damageKind" value in a *.projectile config>
  21. --    }
  22. -- Note that "sourceDamage" can be higher than "damage" if - for instance -
  23. -- some damage was blocked by a shield.
  24. function damage(args) end
  25.  
  26. --- Called when the NPC is interacted with.
  27. -- Available interaction responses are:
  28. --    "OpenCockpitInterface"
  29. --    "SitDown"
  30. --    "OpenCraftingInterface"
  31. --    "OpenCookingInterface"
  32. --    "OpenTechInterface"
  33. --    "Teleport"
  34. --    "OpenSongbookInterface"
  35. --    "OpenNpcCraftingInterface"
  36. --    "OpenTech3DPrinterDialog"
  37. --    "ShowPopup"
  38. --    "ScriptConsole"
  39. --
  40. -- @tab args Map of interaction event arguments:
  41. --    {
  42. --      sourceId = <Entity id of the entity interacting with this NPC>
  43. --      sourcePosition = <The {x,y} position of the interacting entity>
  44. --    }
  45. --
  46. -- @return[1] nil (no interaction response)
  47. -- @treturn[2] string the interaction response that should be performed
  48. -- @treturn[3] array the interaction response and configuration:
  49. --    {
  50. --       <interaction response string>,
  51. --       <interaction response config table (map)>
  52. --    }
  53. function interact(args) end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement