Scripters cove

Discussion and information relevant to creating special missions, new ships, skins etc.

Moderators: winston, another_commander

User avatar
Thargoid
Thargoid
Thargoid
Posts: 5528
Joined: Thu Jun 12, 2008 6:55 pm

Re: Scripters cove

Post by Thargoid »

I believe it does still work, but will confirm later on and give it a severe thrashing if it doesn't...
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: Scripters cove

Post 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.
User avatar
Rorschachhamster
---- E L I T E ----
---- E L I T E ----
Posts: 274
Joined: Sun Aug 05, 2012 11:46 pm
Contact:

Re: Scripters cove

Post by Rorschachhamster »

The black monk gunships have moveable cannons, that point into the direction of a target. Could help, too.
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Re: Scripters cove

Post 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.
User avatar
Rorschachhamster
---- E L I T E ----
---- E L I T E ----
Posts: 274
Joined: Sun Aug 05, 2012 11:46 pm
Contact:

Re: Scripters cove

Post 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:
User avatar
GGShinobi
---- E L I T E ----
---- E L I T E ----
Posts: 291
Joined: Tue Dec 25, 2012 7:20 pm

Re: Scripters cove

Post by GGShinobi »

Thanks everyone for your great tips!! I'll definitely check them out!! :mrgreen:
忍 knowing that enough is enough, you'll always have enough.

Running Oolite 1.77 on Ubuntu Linux 12.04 LTS
Switeck
---- E L I T E ----
---- E L I T E ----
Posts: 2411
Joined: Mon May 31, 2010 11:11 pm

Re: Scripters cove

Post 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.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post 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...
User avatar
GGShinobi
---- E L I T E ----
---- E L I T E ----
Posts: 291
Joined: Tue Dec 25, 2012 7:20 pm

Re: Scripters cove

Post 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:
忍 knowing that enough is enough, you'll always have enough.

Running Oolite 1.77 on Ubuntu Linux 12.04 LTS
User avatar
GGShinobi
---- E L I T E ----
---- E L I T E ----
Posts: 291
Joined: Tue Dec 25, 2012 7:20 pm

HowTo change event handler functions in subentities?

Post 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?
忍 knowing that enough is enough, you'll always have enough.

Running Oolite 1.77 on Ubuntu Linux 12.04 LTS
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Re: HowTo change event handler functions in subentities?

Post 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.
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Scripters cove

Post 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.
User avatar
GGShinobi
---- E L I T E ----
---- E L I T E ----
Posts: 291
Joined: Tue Dec 25, 2012 7:20 pm

Re: HowTo change event handler functions in subentities?

Post 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:
忍 knowing that enough is enough, you'll always have enough.

Running Oolite 1.77 on Ubuntu Linux 12.04 LTS
User avatar
GGShinobi
---- E L I T E ----
---- E L I T E ----
Posts: 291
Joined: Tue Dec 25, 2012 7:20 pm

Re: Possibilities of ship scripting

Post 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?
忍 knowing that enough is enough, you'll always have enough.

Running Oolite 1.77 on Ubuntu Linux 12.04 LTS
User avatar
cim
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 4072
Joined: Fri Nov 11, 2011 6:19 pm

Re: Possibilities of ship scripting

Post 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.
Post Reply