Skip to content

fix for setPlanetRadius breaks setPosition #2304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

csibbitt
Copy link
Contributor

There is some unexpected interaction between setPlanetRadius() and setPosition().

The lua scenario code below works - every 10s the planet gets further from the origin and switches texture. However, if I uncomment the setPlanetRadius(), then the radius and texture update, but the position does not.

function init()
    P = Planet():setPosition(sectorToXY("F6")):setPlanetRadius(2500):setPlanetSurfaceTexture("planets/planet-1.png")
    player = PlayerSpaceship():setTemplate("Phobos M3P"):setPosition(0, 0):setRotation(0)
end

sectorNum = 6
lastupdate = 0
function update(delta)
    lastupdate = lastupdate + delta
    if lastupdate > 10 then
        sectorNum = sectorNum + 1
        P:setPosition(sectorToXY("F" .. sectorNum))
        P:setPlanetSurfaceTexture("planets/planet-" .. (sectorNum % 5) + 1 .. ".png")
        lastupdate = 0
    else
        --P:setPlanetRadius(sectorNum * 500)
    end
end

This patch fixes it. For some reason it was the first thing I tried, and it worked, but I can't yet describe why it fixes it; so not convinced it's the correct thing to do. With this patch, the radius, texture, and position all update as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant