Page 62 of 118

Re: Scripters cove

Posted: Fri Feb 08, 2013 7:30 am
by Thargoid
I believe it does still work, but will confirm later on and give it a severe thrashing if it doesn't...

Re: Scripters cove

Posted: Fri Feb 08, 2013 7:46 am
by Eric Walch
Moveable subentities are also used in
- BuoyRepair.oxp, were the buoy "unfolds" after station launch and "fold" before docking.
- Dredgers.oxp, were the dock is closed but opens up on launch or docking requests.

Re: Scripters cove

Posted: Fri Feb 08, 2013 7:50 am
by Rorschachhamster
The black monk gunships have moveable cannons, that point into the direction of a target. Could help, too.

Re: Scripters cove

Posted: Fri Feb 08, 2013 10:43 am
by Commander McLane
Rorschachhamster wrote:
The black monk gunships have moveable cannons, that point into the direction of a target. Could help, too.
No, that's just simple ball turrets.

Re: Scripters cove

Posted: Fri Feb 08, 2013 12:23 pm
by Rorschachhamster
Commander McLane wrote:
Rorschachhamster wrote:
The black monk gunships have moveable cannons, that point into the direction of a target. Could help, too.
No, that's just simple ball turrets.
Oh. OK. :)
I just thought: "Well, could you make ball turrets that don't shoot?". Would be nifty for navigational arrays, that follow the target... :wink:

Re: Scripters cove

Posted: Fri Feb 08, 2013 5:49 pm
by GGShinobi
Thanks everyone for your great tips!! I'll definitely check them out!! :mrgreen:

Re: Scripters cove

Posted: Fri Feb 08, 2013 11:29 pm
by Switeck
Rorschachhamster wrote:
Commander McLane wrote:
Rorschachhamster wrote:
The black monk gunships have moveable cannons, that point into the direction of a target. Could help, too.
No, that's just simple ball turrets.
Oh. OK. :)
I just thought: "Well, could you make ball turrets that don't shoot?". Would be nifty for navigational arrays, that follow the target... :wink:
This can attract surprising amounts of unwanted attention, as I discovered that even unarmed stations that target other ships can be "viewed" and treated as a hostile.

Re: Scripters cove

Posted: Sat Feb 09, 2013 9:21 am
by cim
cim wrote:
But I'm inclined to think this is a bug: those rare ships that have both frangible subents and shields should obviously have the shields cover the subents too.
Fixed in r5634. Porcupine captains everywhere now can engage in combat without a few thousand in repair bills for their engine casings...

Re: Scripters cove

Posted: Sun Feb 10, 2013 4:27 am
by GGShinobi
cim wrote:
cim wrote:
But I'm inclined to think this is a bug: those rare ships that have both frangible subents and shields should obviously have the shields cover the subents too.
Fixed in r5634. Porcupine captains everywhere now can engage in combat without a few thousand in repair bills for their engine casings...
Great! :D But how can I get that newest version? I've tried "oolite-update", but it didn't seem to work (subentities are still hit before the shields)... :roll:

HowTo change event handler functions in subentities?

Posted: Sun Feb 10, 2013 4:44 am
by GGShinobi
Another question:

related with this question and the above bug I came up with the idea to build a "Subentity Repair System", similar to Thargoids awesome repair bots oxp. :idea: But I'm unable to find out when a subentity is destroyed...

I've tried overriding (extending?) the players.ship.subentities' "shipDied" and "shipBeingAttacked"-functions, but my modifications seemingly have no effect. Here is my main oxp's startup-function, which shows how I tried to achieve it:

Code: Select all

// startup - called when OXP is loaded (on game start, load game,...)
this.startUp = function () {
  // setup "subentity died" functions
  $log("startup:", "running startUp...");
  var x=0;
  for (x=0; x < player.ship.subEntities.length; x++) {
    $log("SubentityModified:", "setting up subEnt: " + player.ship.subEntities[x]);
    $log("SubentityModified:", "player.ship.subEntities[x].shipBeingAttacked b4: " + player.ship.subEntities[x].shipBeingAttacked); // returns undef (as expected)
    player.ship.subEntities[x].shipBeingAttacked = function(whom) {
      message = this + " being attacked!";
      log("SmellySubEnt", message);
      player.consoleMessage(message, 1);
    }
    $log("SubentityModified:", "player.ship.subEntities[x].shipBeingAttacked: " + player.ship.subEntities[x].shipBeingAttacked); // returns the above function => seems it worked
    player.ship.subEntities[x].shipDied = function(whom, why) {
      message = this + " died!!";
      player.commsMessage(message, 3);
      log("SmellySubEnt", message);
      player.consoleMessage(message, 1);
    } 
  }
}
I'm getting no messages / log-entries when a subentity is being attacked or destroyed...

So here my question :?: How can I run code when a subentity has been destroyed?

Re: HowTo change event handler functions in subentities?

Posted: Sun Feb 10, 2013 8:32 am
by Eric Walch
GGShinobi wrote:
I'm getting no messages / log-entries when a subentity is being attacked or destroyed...

So here my question :?: How can I run code when a subentity has been destroyed?
Try:

Code: Select all

player.ship.subEntities[x].script.shipDied = function(whom, why) {
      message = this + " died!!";
      player.commsMessage(message, 3);
      log("SmellySubEnt", message);
      player.consoleMessage(message, 1);
    } 
You must add the code to the ship.script, not the ship itself. :lol:

And you probably must not only use the code on startUp, but also on restoration of the subs.

Re: Scripters cove

Posted: Sun Feb 10, 2013 9:56 am
by cim
GGShinobi wrote:
Great! :D But how can I get that newest version? I've tried "oolite-update", but it didn't seem to work (subentities are still hit before the shields)... :roll:
You can either wait until we release 1.77.1 and then oolite-update will work, or you can download a nightly build (links in a sticky thread at the top of the forum for your OS), or you can build Oolite from SVN yourself.

As we are currently in a "fixing bugs" part of the release cycle, you should be fairly safe using the nightly version. Once 1.78 is released we will move back to the "creating bugs" part of the release cycle and you should switch back to using official releases.

Re: HowTo change event handler functions in subentities?

Posted: Sun Feb 10, 2013 12:12 pm
by GGShinobi
Eric Walch wrote:
GGShinobi wrote:
So here my question :?: How can I run code when a subentity has been destroyed?
Try:

Code: Select all

player.ship.subEntities[x].script.shipDied = function(whom, why) {
      var message = this + " died!!";
      player.commsMessage(message, 3);
      log("SmellySubEnt", message);
      player.consoleMessage(message, 1);
    } 
You must add the code to the ship.script, not the ship itself. :lol:
Oooh man! :roll: *slaps his face* :lol: Eric Walch, thanks a million times! This works like charm!! :mrgreen:
Eric Walch wrote:
And you probably must not only use the code on startUp, but also on restoration of the subs.
Yeah, I actually already found this out "the hard way" before I read your post, but thanks anyway! :mrgreen:
cim wrote:
GGShinobi wrote:
Great! :D But how can I get that newest version? I've tried "oolite-update", but it didn't seem to work (subentities are still hit before the shields)... :roll:
You can either wait until we release 1.77.1 and then oolite-update will work, or you can download a nightly build (links in a sticky thread at the top of the forum for your OS), or you can build Oolite from SVN yourself.

As we are currently in a "fixing bugs" part of the release cycle, you should be fairly safe using the nightly version. Once 1.78 is released we will move back to the "creating bugs" part of the release cycle and you should switch back to using official releases.
cim, thank you very much for the info. It's good to know - but now that my "Ship Entity Repair System" is about to become reality, I'll stick with 1.77, because the buggy behaviour is actually good for testing :mrgreen:

Re: Possibilities of ship scripting

Posted: Sun Feb 10, 2013 7:15 pm
by GGShinobi
cim wrote:
GGShinobi wrote:
  • it is possible to replace the ship/surround it with a comet tail when it activates the jump drive, so that it looks like a real comet? :?:
Surround would be easier, and a Visual Effect is probably the easiest way to do that. Again, frame callbacks to position and orient.
Excuse me, kind sir, in the fine ship, I've got two more questions! :mrgreen:
  • Is it possible to create Visual Effects which are "transparent" from within (so I can see through the comet effect when looking out of the cockpit) but appear "solid" from the outside? If so, how?
  • Can Visual Effects also be used as the model that is shown on the mission screen?

Re: Possibilities of ship scripting

Posted: Sun Feb 10, 2013 7:21 pm
by cim
GGShinobi wrote:
  • Is it possible to create Visual Effects which are "transparent" from within (so I can see through the comet effect when looking out of the cockpit) but appear "solid" from the outside? If so, how?
  • Can Visual Effects also be used as the model that is shown on the mission screen?
1) Yes. All models are transparent from the inside, unless you've built them inside-out. So as long as the model's shape is purely convex and the internal camera positions are inside the model (and the external ones outside it) you'll be fine.
2) No, but in that context you don't need to worry about such things as collisions, so you can just use a ship with the same model.