Open
Conversation
Lua pairs loops for model data include a string.sub() call to
ignore keys starting with two underscores (__).
for k, v in pairs(__model_data[model]) do
if string.sub(1, 2) ~= "__" then
...
However, instead of passing the key string in the first argument,
which expects the string to substring, this passes the position
index of 1. So instead of checking as expected:
string.sub("__some_string", 1, 2) ~= "__"
It effectively checks:
string.sub("1", 2) ~= "__"
which is always true.
Fix this by passing the key in the string.sub() call.
ModelData:addTubePosition() doesn't accept any arguments, when it should accept x, y, and z coordinates, the same as addBeamPosition(). Add the missing arguments.
AIController ship Lua function orderFlyFormation() takes two arguments, offset_x and offset_y, but doesn't use them. It instead uses x and y, which are valid globals with unexpected or nil values when this function is called. Use the offset values passed to the function.
Also, fix the broken ScienceDatabase hasEntries() function, which attempts to call an undefined global getEntries() function instead of self:getEntries().
Reject negative argument values. Remove a broken validation Boolean from addReputationPoints() that seemed to check against subtracting too many points, but nearly always returned an incorrect value of true.
daid
reviewed
Feb 21, 2026
scripts/api/entity/spaceobject.lua
Outdated
| function Entity:setHeading(heading) | ||
| if self.components.transform then self.components.transform.rotation = heading + 270 end | ||
| if self.components.transform then | ||
| local heading = self.components.transform.rotation + 270 |
Owner
There was a problem hiding this comment.
This looks wrong, as it's not taking the parameter passed but the current rotation.
Contributor
Author
There was a problem hiding this comment.
Rewrote both to use modulo in 3f4dfb9.
> player=getPlayerShip(-1)
> player:getHeading()
193.6946105957
> player:setHeading(540)
entity: 0xce
> player:getHeading()
180.0
> player:setHeading(0)
entity: 0xce
> player:getHeading()
0.0
> player:setHeading(-90)
entity: 0xce
> player:getHeading()
270.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
string.sub()calls re: model data that forget to pass the string into the function's first argumentModelData:addTubePosition()offset_x/_yarguments passed toorderFlyFormation()instead of invalid globalsx/yhasEntries(), which still doesn't work as documented anyway due to [Regression] getScienceDatabases() global no longer exists #2615 / [#2615] Attempt to restore getScienceDatabases() function #2617deepcopy()to copy modelData by value forScienceDatabase:setModelDataName(), aligned with other uses ofdeepcopy()for modelDatadockinginstead ofopening,dockedinstead ofhailed)setPlanetCloudRadius(), warpjammerget/setRange()missingcomponentsreferencespinwith function argumentrotation_timein planetsetAxialRotationTime()hailed_playerstate inisCommsBeingHailed()addBroadcast()color assignments; hostile is gray and neutral is redget/setWeaponTube...()functionstake/addReputationPoints()setRadarTrace()addEngineEmitter()getHeading()to 0-360 rangeorderFlyFormation()assigning a different case to the order string than the enum