debris.script 380 B

1234567891011121314151617
  1. function init(self)
  2. self.t = 2 -- <1>
  3. end
  4. function update(self, dt)
  5. self.t = self.t - dt -- <2>
  6. if self.t < 0 then
  7. go.delete() -- <3>
  8. end
  9. end
  10. --[[
  11. 1. Store a value `t` in the current script component (`self`).
  12. 2. Decrease `t` with delta time (elapsed since last call to `update()`).
  13. 3. If `t` is below 0, delete the current game object
  14. ("." is shorthand for that).
  15. --]]