diff --git a/scripts/randstar.celx b/scripts/randstar.celx index 62d883228..a459913bd 100644 --- a/scripts/randstar.celx +++ b/scripts/randstar.celx @@ -6,6 +6,6 @@ while 1 do index = math.floor(nstars * math.random()) star = celestia:getstar(index) celestia:select(star) - obs:goto(star, 10) + obs:gotoobject(star, 10) wait(10) end diff --git a/scripts/tour-system.celx b/scripts/tour-system.celx index c2f0d7d4c..0a8e40464 100644 --- a/scripts/tour-system.celx +++ b/scripts/tour-system.celx @@ -1,7 +1,7 @@ -function goto(o, t) +function gotoobject(o, t) local obs = celestia:getobserver() obs:follow(o) - obs:goto(o, t) + obs:gotoobject(o, t) while (obs:travelling()) do wait(0) end @@ -11,7 +11,7 @@ function visit(o) local i, v celestia:select(o) celestia:flash(o:type() .. " - " .. o:name()) - goto(o, 3) + gotoobject(o, 3) wait(0.5) local children = o:getchildren() for i, v in ipairs(children) do diff --git a/scripts/z-dist.celx b/scripts/z-dist.celx index f093f50b4..6f1ce168a 100644 --- a/scripts/z-dist.celx +++ b/scripts/z-dist.celx @@ -20,7 +20,7 @@ end function rgb2hex(r,g,b) -- Converts color code from RGB to Hex - local hex = string.format("#%.2x%.2x%.2x", r,g,b) + local hex = string.format("#%.2x%.2x%.2x", math.floor(r), math.floor(g), math.floor(b)) return hex end @@ -117,4 +117,4 @@ while true do celestia:print(sel:name()..": "..string.format("redshift z = %5.3f, distance = %5.2f Mpc", z,d).."\nmax. redshift: "..dsomax:name(),5,-1,-1,0,6) end wait(0) -end \ No newline at end of file +end diff --git a/src/celestia/celx.cpp b/src/celestia/celx.cpp index 0d855ee25..f38877a64 100644 --- a/src/celestia/celx.cpp +++ b/src/celestia/celx.cpp @@ -512,7 +512,11 @@ LuaState::LuaState() : ioMode(NoIO), eventHandlerEnabled(false) { +#if LUA_VER >= 0x050100 state = luaL_newstate(); +#else + state = lua_open(); +#endif timer = CreateTimer(); screenshotCount = 0; } @@ -3548,6 +3552,9 @@ bool LuaState::init(CelestiaCore* appCore) openLuaLibrary(state, LUA_MATHLIBNAME, luaopen_math); openLuaLibrary(state, LUA_TABLIBNAME, luaopen_table); openLuaLibrary(state, LUA_STRLIBNAME, luaopen_string); +#if LUA_VER >= 0x050200 + openLuaLibrary(state, LUA_COLIBNAME, luaopen_coroutine); +#endif // Make the package library, except the loadlib function, available // for celx regardless of script system access policy. allowLuaPackageAccess(); diff --git a/src/celestia/celx_observer.cpp b/src/celestia/celx_observer.cpp index f5ec0bed6..0340478a9 100644 --- a/src/celestia/celx_observer.cpp +++ b/src/celestia/celx_observer.cpp @@ -895,7 +895,10 @@ void CreateObserverMetaTable(lua_State* l) celx.registerMethod("__tostring", observer_tostring); celx.registerMethod("isvalid", observer_isvalid); +#if LUA_VER < 0x050200 celx.registerMethod("goto", observer_goto); +#endif + celx.registerMethod("gotoobject", observer_goto); celx.registerMethod("gotolonglat", observer_gotolonglat); celx.registerMethod("gotolocation", observer_gotolocation); celx.registerMethod("gotodistance", observer_gotodistance);