Bobs scripting woes

Luomu
Posts: 58
Joined: Mon Jul 01, 2013 1:30 am

Re: Bobs scripting woes

Post by Luomu »

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:
body the Body the Player was docked with (a SpaceStation) or landed on (a Planet)
Bug or wrong documentation? Since onJettison returns the ship, it would be easy to understand where the bug comes from...
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
Posts: 76
Joined: Sat Jul 06, 2013 6:04 pm

Re: Bobs scripting woes

Post by TheBob »

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...
Luomu
Posts: 58
Joined: Mon Jul 01, 2013 1:30 am

Re: Bobs scripting woes

Post by Luomu »

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.
TheBob
Posts: 76
Joined: Sat Jul 06, 2013 6:04 pm

Re: Bobs scripting woes

Post by TheBob »

The engine is just not meant to handle that.
Yeah, I was quite afraid of that. Change of plans then. Will have to see what the most sensible (and most fun) options are.
TheBob
Posts: 76
Joined: Sat Jul 06, 2013 6:04 pm

Re: Bobs scripting woes

Post by TheBob »

Waaaaaait a moment... is there a way to prevent a ship type from being sold at a shipyard?
Luomu
Posts: 58
Joined: Mon Jul 01, 2013 1:30 am

Re: Bobs scripting woes

Post by Luomu »

TheBob wrote:Waaaaaait a moment... is there a way to prevent a ship type from being sold at a shipyard?
Depends if this gets merged: https://github.com/pioneerspacesim/pioneer/pull/2361
robn
Posts: 302
Joined: Mon Jul 01, 2013 1:11 am
Location: Melbourne, Australia

Re: Bobs scripting woes

Post by robn »

So merged. It'll be in the next build, today sometime.
TheBob
Posts: 76
Joined: Sat Jul 06, 2013 6:04 pm

Re: Bobs scripting woes

Post by TheBob »

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...
shadmar
Posts: 25
Joined: Mon Jul 01, 2013 7:28 pm

Re: Bobs scripting woes

Post by shadmar »

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...
We added some bits in pragon for removing bodies :

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 }
   }; 
Then in scripts just call :

Code: Select all

cargo:Remove()
you could also remove planets, spacestation etc.. this way.. probably with issues but still..
robn
Posts: 302
Joined: Mon Jul 01, 2013 1:11 am
Location: Melbourne, Australia

Re: Bobs scripting woes

Post by robn »

shadmar wrote:We added some bits in pragon for removing bodies :
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 :)

Its slowly being fixed, but the changes have other dependencies that I'm working through, so its a way off yet.
you could also remove planets, spacestation etc.. this way.. probably with issues but still..
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.

Oh, and you probably wouldn't want to remove the player either ;)
Post Reply