void ObjectViewerView::OnChangeTerrain() { const fixed volatileGas = fixed(65536.0*atof(m_sbodyVolatileGas->GetText().c_str()), 65536); const fixed volatileLiquid = fixed(65536.0*atof(m_sbodyVolatileLiquid->GetText().c_str()), 65536); const fixed volatileIces = fixed(65536.0*atof(m_sbodyVolatileIces->GetText().c_str()), 65536); const fixed life = fixed(65536.0*atof(m_sbodyLife->GetText().c_str()), 65536); const fixed volcanicity = fixed(65536.0*atof(m_sbodyVolcanicity->GetText().c_str()), 65536); const fixed metallicity = fixed(65536.0*atof(m_sbodyMetallicity->GetText().c_str()), 65536); const fixed mass = fixed(65536.0*atof(m_sbodyMass->GetText().c_str()), 65536); const fixed radius = fixed(65536.0*atof(m_sbodyRadius->GetText().c_str()), 65536); // XXX this is horrendous, but probably safe for the moment. all bodies, // terrain, whatever else holds a const pointer to the same toplevel // sbody. one day objectviewer should be far more contained and not // actually modify the space Body *body = Pi::player->GetNavTarget(); SBody *sbody = const_cast<SBody*>(body->GetSBody()); sbody->seed = atoi(m_sbodySeed->GetText().c_str()); sbody->radius = radius; sbody->mass = mass; sbody->m_metallicity = metallicity; sbody->m_volatileGas = volatileGas; sbody->m_volatileLiquid = volatileLiquid; sbody->m_volatileIces = volatileIces; sbody->m_volcanicity = volcanicity; sbody->m_life = life; // force reload if (body->IsType(Object::TERRAINBODY)) static_cast<TerrainBody*>(body)->GetGeoSphere()->OnChangeDetailLevel(); }
/* * Attribute: seed * * The random seed used to generate this <Body>. This is guaranteed to be the * same for this body across runs of the same build of the game, and should be * used to seed a <Rand> object when you want to ensure the same random * numbers come out each time. * * Availability: * * alpha 10 * * Status: * * stable */ static int l_body_attr_seed(lua_State *l) { Body *b = LuaBody::GetFromLua(1); const SBody *sbody = b->GetSBody(); assert(sbody); lua_pushinteger(l, sbody->seed); return 1; }
/* * Attribute: superType * * The supertype of the body, as a <Constants.BodySuperType> constant * * Only valid for non-dynamic <Bodies>. For dynamic bodies <superType> will be nil. * * Availability: * * alpha 10 * * Status: * * stable */ static int l_body_attr_super_type(lua_State *l) { Body *b = LuaBody::GetFromLua(1); const SBody *sbody = b->GetSBody(); if (!sbody) { lua_pushnil(l); return 1; } lua_pushstring(l, LuaConstants::GetConstantString(l, "BodySuperType", sbody->GetSuperType())); return 1; }
/* * Attribute: path * * The <SystemPath> that points to this body. * * If the body is a dynamic body it has no persistent path data, and its * <path> value will be nil. * * Availability: * * alpha 10 * * Status: * * stable */ static int l_body_attr_path(lua_State *l) { Body *b = LuaBody::GetFromLua(1); const SBody *sbody = b->GetSBody(); if (!sbody) { lua_pushnil(l); return 1; } SystemPath path = Pi::currentSystem->GetPath(); path.bodyIndex = sbody->id; LuaSystemPath::PushToLua(&path); return 1; }