Bug. I can see it in data/libs/Ship.lua. The C++ version used to return the body you were landed on, but when it was moved to purely lua it retuns self (aka player).TheBob wrote:Through a bit more experimentation, I found out that body actually returns the player (at least body.label is the same as the player label).
According to the docummentation, this shouldn't be the case:
Bug or wrong documentation? Since onJettison returns the ship, it would be easy to understand where the bug comes from...body the Body the Player was docked with (a SpaceStation) or landed on (a Planet)
Bobs scripting woes
Re: Bobs scripting woes
Re: Bobs scripting woes
Thanks, I made an issue out of it. Now why does that sound so negative... ?
On we go: I suppose Ship:SpawnCargo is not supposed to work when the ship is landed? that's quite a pitty... How else am I going to deploy my survey bots on the surface? Dropping them seems kind of weird. Then again, might be worth a try. Drop them on the surface, then pick them up some time later. One further problem I see coming, however, is that there doesn't seem to be a call to remove a cargo body...
On we go: I suppose Ship:SpawnCargo is not supposed to work when the ship is landed? that's quite a pitty... How else am I going to deploy my survey bots on the surface? Dropping them seems kind of weird. Then again, might be worth a try. Drop them on the surface, then pick them up some time later. One further problem I see coming, however, is that there doesn't seem to be a call to remove a cargo body...
Re: Bobs scripting woes
The engine is just not meant to handle that. If you spawned cargo on surface it'd probably bounce around a bit and then sink through the ground. Reliably putting down an actual physical thing which you can later locate and retrieve would require some new capabilities.
If you are doing a survey mission for now it's best if the 'probe' transmits results instantly, or after some delay.
If you are doing a survey mission for now it's best if the 'probe' transmits results instantly, or after some delay.
Re: Bobs scripting woes
Yeah, I was quite afraid of that. Change of plans then. Will have to see what the most sensible (and most fun) options are.The engine is just not meant to handle that.
Re: Bobs scripting woes
Waaaaaait a moment... is there a way to prevent a ship type from being sold at a shipyard?
Re: Bobs scripting woes
Depends if this gets merged: https://github.com/pioneerspacesim/pioneer/pull/2361TheBob wrote:Waaaaaait a moment... is there a way to prevent a ship type from being sold at a shipyard?
Re: Bobs scripting woes
So merged. It'll be in the next build, today sometime.
Re: Bobs scripting woes
Yesssss, thanks a lot. Deployable survey bots, here I come! Now how did that G-Max work again? it's been such a long time...
Re: Bobs scripting woes
We added some bits in pragon for removing bodies :TheBob wrote:Thanks, I made an issue out of it. Now why does that sound so negative... ?
On we go: I suppose Ship:SpawnCargo is not supposed to work when the ship is landed? that's quite a pitty... How else am I going to deploy my survey bots on the surface? Dropping them seems kind of weird. Then again, might be worth a try. Drop them on the surface, then pick them up some time later. One further problem I see coming, however, is that there doesn't seem to be a call to remove a cargo body...
In LuaBody.cpp
Code: Select all
//XXX docs
static int l_body_remove(lua_State *l)
{
Body *s = LuaObject<Body>::CheckFromLua(1);
//const std::string label(luaL_checkstring(l, 2));
Pi::game->GetSpace()->KillBody(s);
return 0;
}
..
static luaL_Reg l_methods[] = {
{ "IsDynamic", l_body_is_dynamic },
{ "DistanceTo", l_body_distance_to },
{ "Remove", l_body_remove },
{ 0, 0 }
};
Code: Select all
cargo:Remove()
Re: Bobs scripting woes
I think right now that's safe, but do take extreme care doing stuff like that from Lua. The Game/Space TimeStep methods are extremely picky about the way things are ordered. You probably already know this :)shadmar wrote:We added some bits in pragon for removing bodies :
Its slowly being fixed, but the changes have other dependencies that I'm working through, so its a way off yet.
Right now I wouldn't attempt it for static bodies without extra code to clean up frames and and the SystemBody list. A lot of extra code, I expect.you could also remove planets, spacestation etc.. this way.. probably with issues but still..
Oh, and you probably wouldn't want to remove the player either ;)