Skip to content

Commit

Permalink
Improve Lua type information
Browse files Browse the repository at this point in the history
- Add type information to Event.Register
- Add additional method prototypes to Ship.meta.lua
  • Loading branch information
sturnclaw committed Oct 10, 2024
1 parent e1c9f0b commit 619a750
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 0 deletions.
2 changes: 2 additions & 0 deletions data/libs/Event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,8 @@ Event.New = function()
--
-- stable
--
---@param name string
---@param cb function
self.Register = function (name, cb)
super.Register(self, name, package.modulename(2), cb)
end
Expand Down
15 changes: 15 additions & 0 deletions data/meta/CoreObject/Ship.meta.lua
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,18 @@ function Ship:GetShieldsPercent() end
-- Sets the thruster fuel tank of the ship to the given percentage of its maximum.
---@param percent number
function Ship:SetFuelPercent(percent) end

-- Update ship properties after changing ship equipment or cargo
function Ship:UpdateEquipStats() end

-- Is this ship currently docked with anything?
---@return boolean
function Ship:IsDocked() end

-- Is this ship currently landed on a planet?
---@return boolean
function Ship:IsLanded() end

-- Get the starport this ship is docked with, if any
---@return SpaceStation?
function Ship:GetDockedWith() end
5 changes: 5 additions & 0 deletions data/meta/Engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,9 @@ local Engine = {}

-- TODO: add information about Engine methods

-- Get a model file by name
---@param name string
---@return SceneGraph.Model model
function Engine.GetModel(name) end

return Engine
23 changes: 23 additions & 0 deletions data/meta/Model.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
-- Copyright © 2008-2024 Pioneer Developers. See AUTHORS.txt for details
-- Licensed under the terms of the GPL v3. See licenses/GPL-3.txt

-- This file implements type information about C++ classes for Lua static analysis

---@meta

---@class SceneGraph.Model
---
---@field name string
---@field pattern integer Current pattern applied to the model
---@field numPatterns integer Number of patterns supported by the model

---@class SceneGraph.Model
local Model = {}

-- Set the pattern currently applied to the model
---@param idx integer
function Model:SetPattern(idx) end

-- Set debug flags used when rendering this model
---@param flags ModelDebugFlags[]
function Model:SetDebugFlags(flags) end

0 comments on commit 619a750

Please sign in to comment.