Fix some more stuff

- Rename CameraAPI.Pos to CameraAPI.GetPos
- Change some EmmyLua annotations that are supposedly wrong
- Remove debug printing
- Other small fixes
This commit is contained in:
David Vogel 2022-07-23 17:45:06 +02:00
parent 98dfb5fbb0
commit 98370f6737
5 changed files with 9 additions and 13 deletions

View File

@ -76,7 +76,7 @@ end
---@param viewportCenter Vec2|nil -- Result of `GameGetCameraPos()`. Will be queried automatically if set to nil. ---@param viewportCenter Vec2|nil -- Result of `GameGetCameraPos()`. Will be queried automatically if set to nil.
---@return Vec2 window ---@return Vec2 window
function Coords:ToWindow(world, viewportCenter) function Coords:ToWindow(world, viewportCenter)
viewportCenter = viewportCenter or CameraAPI.Pos() viewportCenter = viewportCenter or CameraAPI.GetPos()
local internalTopLeft, internalBottomRight = self:InternalRect() local internalTopLeft, internalBottomRight = self:InternalRect()
local pixelScale = self:PixelScale() local pixelScale = self:PixelScale()
@ -89,7 +89,7 @@ end
---@param viewportCenter Vec2|nil -- Result of `GameGetCameraPos()`. Will be queried automatically if set to nil. ---@param viewportCenter Vec2|nil -- Result of `GameGetCameraPos()`. Will be queried automatically if set to nil.
---@return Vec2 world ---@return Vec2 world
function Coords:ToWorld(window, viewportCenter) function Coords:ToWorld(window, viewportCenter)
viewportCenter = viewportCenter or CameraAPI.Pos() viewportCenter = viewportCenter or CameraAPI.GetPos()
local internalTopLeft, internalBottomRight = self:InternalRect() local internalTopLeft, internalBottomRight = self:InternalRect()
local pixelScale = self:PixelScale() local pixelScale = self:PixelScale()

View File

@ -47,12 +47,12 @@ function EntityRemoveComponent(entity_id, component_id) end
function EntityGetAllComponents(entity_id) end function EntityGetAllComponents(entity_id) end
---@param entity_id number ---@param entity_id number
---@param component_type_name string ---@param component_type_name string
---@param tag string "" ---@param tag string|nil
---@return number[]|nil component_id ---@return number[]|nil component_id
function EntityGetComponent(entity_id, component_type_name, tag) end function EntityGetComponent(entity_id, component_type_name, tag) end
---@param entity_id number ---@param entity_id number
---@param component_type_name string ---@param component_type_name string
---@param tag string "" ---@param tag string|nil
---@return number|nil component_id ---@return number|nil component_id
function EntityGetFirstComponent(entity_id, component_type_name, tag) end function EntityGetFirstComponent(entity_id, component_type_name, tag) end
---@param entity_id number ---@param entity_id number
@ -358,8 +358,8 @@ function AddMaterialInventoryMaterial(entity_id, material_name, count) end
---@return number material_type ---@return number material_type
function GetMaterialInventoryMainMaterial(entity_id) end function GetMaterialInventoryMainMaterial(entity_id) end
---@param strength number ---@param strength number
---@param x number camera_x ---@param x number|nil -- Defaults to camera position
---@param y number camera_y ---@param y number|nil -- Defaults to camera position
function GameScreenshake(strength, x, y) end function GameScreenshake(strength, x, y) end
function GameOnCompleted() end function GameOnCompleted() end
---@param id string ---@param id string

View File

@ -28,7 +28,7 @@ end
---Returns the center position of the viewport in world/virtual coordinates. ---Returns the center position of the viewport in world/virtual coordinates.
---@return Vec2 ---@return Vec2
function CameraAPI.Pos() function CameraAPI.GetPos()
return Vec2(GameGetCameraPos()) return Vec2(GameGetCameraPos())
end end

View File

@ -42,10 +42,6 @@ package.loaded = package.loaded or {
--os = os, --os = os,
} }
for k, v in pairs(package.loaded) do
print(k, v)
end
---Emulated require function in case the Lua API is restricted. ---Emulated require function in case the Lua API is restricted.
---It's probably good enough for most usecases. ---It's probably good enough for most usecases.
---@param modName string ---@param modName string

View File

@ -92,7 +92,7 @@ end
--- ---
---@param componentTypeName string ---@param componentTypeName string
---@param tableOfComponentValues string[]|nil ---@param tableOfComponentValues string[]
---@return NoitaComponent|nil ---@return NoitaComponent|nil
function NoitaEntity:AddComponent(componentTypeName, tableOfComponentValues) function NoitaEntity:AddComponent(componentTypeName, tableOfComponentValues)
local componentID = EntityAddComponent(self.ID, componentTypeName, tableOfComponentValues) local componentID = EntityAddComponent(self.ID, componentTypeName, tableOfComponentValues)
@ -238,7 +238,7 @@ end
---@return string[] ---@return string[]
function NoitaEntity:GetTags() function NoitaEntity:GetTags()
---@type string ---@type string
local tagsString = EntityGetTags(self.ID) local tagsString = EntityGetTags(self.ID) or ""
local result = {} local result = {}
for tag in tagsString:gmatch('([^,]+)') do for tag in tagsString:gmatch('([^,]+)') do
table.insert(result, tag) table.insert(result, tag)