Already done. Hmm, I thought I’d documented it, but apparently not. Still, look here. Note that sound names enclosed in square brackets will be looked up in customsounds.plist.Frame wrote:Javascript
loadSound("sound.ogg")
playSound.("sound.ogg")
whereby sounds can overlap... playMusic will stop any current music playing...
Scripting requests
Moderators: winston, another_commander
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
E-mail: [email protected]
- Commander McLane
- ---- 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:
Done. – Ahruman
What about the pseudoFixedDxyz_numbers? (See one post above the quoted one.)
It would also help if one of the code wizards could provide us with the formula used for the calculation of pseudoFixedD100_numbers and pseudoFixedD256_numbers. Then we could recreate it as a JS-resource.
(I was even thinking of flying around through all systems in all galaxies, writing down the respective numbers and putting them in an array. But this is a really tedious undertaking, so I wouldn't really like to do it.)
Thanks!Ahruman wrote:Done.Commander McLane wrote:Not a request for a new functionality, but for a change in the existing one. I would like the shipLaunchedEscapePod-event handler to fire a little earlier. To be precise: before player.bounty is reset to 0.
What about the pseudoFixedDxyz_numbers? (See one post above the quoted one.)
It would also help if one of the code wizards could provide us with the formula used for the calculation of pseudoFixedD100_numbers and pseudoFixedD256_numbers. Then we could recreate it as a JS-resource.
(I was even thinking of flying around through all systems in all galaxies, writing down the respective numbers and putting them in an array. But this is a really tedious undertaking, so I wouldn't really like to do it.)
- Commander McLane
- ---- 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:
Request
Very simple, forces the player to dock with entity (if entity can be docked with)
Similar to instant dock with auto pilot, which however only works for the build in stations afaik...
Code: Select all
ship.dock(entity)
player.ship.dock(entity)
Similar to instant dock with auto pilot, which however only works for the build in stations afaik...
Bounty Scanner
Number 935
Number 935
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Done by another_commander – Ahruman
I like to see an event handler for buying equipment. That would it make possible to immediately initialise equipment after purchase. e.g. this equipment could be a custom "remove specific equipment", like the remove passenger berth or remove missiles.
A script could than divine a remove equipment that only shows as he has the equipment. With the handler the oxp can immediately remove the just bought remove-equipment and the equipment itself. After this the normal code will update the screen were the just removed equipment is probably shown again when the tech level is right.
The right place to put the handler would be in "playerEntity.m" in the function "buySelectedItem":
It should offer the equipment name as parameter. I added the line in above code. I'm not sure if the argument is defined right. (I just copied it from a few lines below in the code)
A script could than divine a remove equipment that only shows as he has the equipment. With the handler the oxp can immediately remove the just bought remove-equipment and the equipment itself. After this the normal code will update the screen were the just removed equipment is probably shown again when the tech level is right.
The right place to put the handler would be in "playerEntity.m" in the function "buySelectedItem":
Code: Select all
if ([self tryBuyingItem:item])
{
if (credits == old_credits)
{
[self playCantBuyCommodity];
}
else
{
[self playBuyCommodity];
// wind the clock forward by 10 minutes plus 10 minutes for every 60 credits spent
double time_adjust = (old_credits > credits) ? (old_credits - credits) : 0.0;
ship_clock_adjust += time_adjust + 600.0;
[self doScriptEvent:@"boughtEquipment" withArgument:[[equipdata arrayAtIndex:index] stringAtIndex:EQUIPMENT_KEY_INDEX]];
}
UPS-Courier & DeepSpacePirates & others at the box and some older versions
-
- Quite Grand Sub-Admiral
- Posts: 6682
- Joined: Wed Feb 28, 2007 7:54 am
Eric Walch wrote:I like to see an event handler for buying equipment. That would it make possible to immediately initialise equipment after purchase. e.g. this equipment could be a custom "remove specific equipment", like the remove passenger berth or remove missiles.
A script could than divine a remove equipment that only shows as he has the equipment. With the handler the oxp can immediately remove the just bought remove-equipment and the equipment itself. After this the normal code will update the screen were the just removed equipment is probably shown again when the tech level is right.
The above example handler will generate on the stderr:Code: Select all
It should offer the equipment name as parameter. I added the line in above code. I'm not sure if the argument is defined right. (I just copied it from a few lines below in the code)[/quote] Done. The handler is called [b]playerBoughtEquipment[/b] and is taking the EQ_* key string as parameter. The handler is used in a script as shown here: [code] this.playerBoughtEquipment = function(equipmentKey) { log("playerBoughtEquipment","Player has bought equipment: " + equipmentKey); }
Thanks for pointing out the correct place to look at the code, Eric. It made things really easy.Code: Select all
2008-09-17 14:19:39.369 oolite.exe[5604] [playerBoughtEquipment]: Player has bought equipment: EQ_WEAPON_MILITARY_LASER 2008-09-17 14:19:40.994 oolite.exe[5604] [playerBoughtEquipment]: Player has bought equipment: EQ_PASSENGER_BERTH 2008-09-17 14:19:44.119 oolite.exe[5604] [playerBoughtEquipment]: Player has bought equipment: EQ_ADVANCED_NAVIGATIONAL_ARRAY
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
Thanks Another Commander,
I immediately have an other request. Probably just as simple to implement:
Make the destination of a ship available to the script as read/write.
Currently oolites JS engine offers a bunch of very interesting vector- and quarternion functions to do geometrical calculations. It would be very useful when you could send a ship to such a calculated spot.
e.g
a) For the launches of the GRS station I original had problems that launching ships, often hit the planet. Because of its size it mass locked the exiting ships quite long. With the AI I only can send it to an existing object. Now I sent it to the witchspace coordinates with the special AI command, but for some station locations it still blocks the way and I would rather have used a calculated spot near the station.
b) For the next buoyRepair.oxp release, I send ships between the external GRS structures. I do this by giving each ship his unique a marker in deep space. Than I calculate a position, move the marker to that position, let the AI set the destination to the marker, and move the marker back to deep space. The marker moves in and out in one update so it never shows on the screen. Direct changing of the ships destination variable by JS would be much easier.
c) I also see a good use of this in combat. I always find it very stupid that a fleeing ship goes directly away from the player. When the player is following him he can just toast him from behind as there are no direction changes while fleeing. However, with JS you could in regular intervals check the angle between the headings of the fleeing and attacking ship. When the are close to zero (same heading), the fleeing ship could switch course. This will make it a much harder target.(But maybe this behaviour should be build in Oolite itself : BEHAVIOUR_FLEEING?)
I immediately have an other request. Probably just as simple to implement:
Make the destination of a ship available to the script as read/write.
Currently oolites JS engine offers a bunch of very interesting vector- and quarternion functions to do geometrical calculations. It would be very useful when you could send a ship to such a calculated spot.
e.g
a) For the launches of the GRS station I original had problems that launching ships, often hit the planet. Because of its size it mass locked the exiting ships quite long. With the AI I only can send it to an existing object. Now I sent it to the witchspace coordinates with the special AI command, but for some station locations it still blocks the way and I would rather have used a calculated spot near the station.
b) For the next buoyRepair.oxp release, I send ships between the external GRS structures. I do this by giving each ship his unique a marker in deep space. Than I calculate a position, move the marker to that position, let the AI set the destination to the marker, and move the marker back to deep space. The marker moves in and out in one update so it never shows on the screen. Direct changing of the ships destination variable by JS would be much easier.
c) I also see a good use of this in combat. I always find it very stupid that a fleeing ship goes directly away from the player. When the player is following him he can just toast him from behind as there are no direction changes while fleeing. However, with JS you could in regular intervals check the angle between the headings of the fleeing and attacking ship. When the are close to zero (same heading), the fleeing ship could switch course. This will make it a much harder target.(But maybe this behaviour should be build in Oolite itself : BEHAVIOUR_FLEEING?)
UPS-Courier & DeepSpacePirates & others at the box and some older versions
Done – Ahruman
And one from me, based on the same discussion with Eric. Would it be possible to expand the AI command sendScriptMessage to accept parameters, so we can use it to pass them to the function in the script?
I was trying to use it yesterday to sort out messaging by passing the message needed from the AI "sendScriptMessage: playerComms('Your message here')" to a function this.playerComms(message) in the ships script which diplayed the parameter message, but nothing was passed hence nothing displayed...
Having to code each message as a separate function works, but is rather a bodged way of doing it. I know the messaging from unpiloted craft is due in 1.72, but consider this just an example
I was trying to use it yesterday to sort out messaging by passing the message needed from the AI "sendScriptMessage: playerComms('Your message here')" to a function this.playerComms(message) in the ships script which diplayed the parameter message, but nothing was passed hence nothing displayed...
Having to code each message as a separate function works, but is rather a bodged way of doing it. I know the messaging from unpiloted craft is due in 1.72, but consider this just an example
My OXPs via Boxspace or from my Wiki pages .
Thargoid TV
Dropbox Referral Link
Thargoid TV
Dropbox Referral Link
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
This is problematic because the meaning of destination depends on AI state, and various bits of code write to it at potentially unpredictable times. Its meaning varies; it’s sometimes in absolute coordinates, sometimes relative to the ship. Its usages may change in future, as well.Eric Walch wrote:Thanks Another Commander,
I immediately have an other request. Probably just as simple to implement:
Make the destination of a ship available to the script as read/write.
Done. Syntax is:Thargoid wrote:color=green]And one from me, based on the same discussion with Eric. Would it be possible to expand the AI command sendScriptMessage to accept parameters, so we can use it to pass them to the function in the script?
Code: Select all
sendScriptMessage: functionName parameter string
Code: Select all
sendScriptMessage: functionName foo bar baz
E-mail: [email protected]
- Commander McLane
- ---- 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:
Hey, I had already requested the same thing two posts (and seven weeks) earlier. Why am I not stroken out?Eric Walch wrote:Done by another_commander – Ahruman[/b]
I like to see an event handler for buying equipment. That would it make possible to immediately initialise equipment after purchase. e.g. this equipment could be a custom "remove specific equipment", like the remove passenger berth or remove missiles.
A script could than divine a remove equipment that only shows as he has the equipment. With the handler the oxp can immediately remove the just bought remove-equipment and the equipment itself. After this the normal code will update the screen were the just removed equipment is probably shown again when the tech level is right.
The right place to put the handler would be in "playerEntity.m" in the function "buySelectedItem":
It should offer the equipment name as parameter. I added the line in above code. I'm not sure if the argument is defined right. (I just copied it from a few lines below in the code)Code: Select all
if ([self tryBuyingItem:item]) { if (credits == old_credits) { [self playCantBuyCommodity]; } else { [self playBuyCommodity]; // wind the clock forward by 10 minutes plus 10 minutes for every 60 credits spent double time_adjust = (old_credits > credits) ? (old_credits - credits) : 0.0; ship_clock_adjust += time_adjust + 600.0; [self doScriptEvent:@"boughtEquipment" withArgument:[[equipdata arrayAtIndex:index] stringAtIndex:EQUIPMENT_KEY_INDEX]]; }
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
In that case maybe make it possible to write coordinates that are used by the AI command "setDestinationFromCoordinates". This way the coordinates can be set by a script message that does something similar as "setCoordinates: wpu 0 0 0.3".Ahruman wrote:This is problematic because the meaning of destination depends on AI state, and various bits of code write to it at potentially unpredictable times. Its meaning varies; it’s sometimes in absolute coordinates, sometimes relative to the ship. Its usages may change in future, as well.Eric Walch wrote:Make the destination of a ship available to the script as read/write.
It makes use a little bit more complicated but will work like:
"setCoordinates: wpu 0 0 0.3", setDestinationFromCoordinates, but not with fixed coordinates but coordinates calculated by a scriptMessage.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
- JensAyton
- Grand Admiral Emeritus
- Posts: 6657
- Joined: Sat Apr 02, 2005 2:43 pm
- Location: Sweden
- Contact:
Because I got bored. :-)Commander McLane wrote:Hey, I had already requested the same thing two posts (and seven weeks) earlier. Why am I not stroken out? :P
E-mail: [email protected]
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
I like to have a remove method. It should work the same as the explode method but without the explosion itself. Currently people are using the landOnPlanet AI command for this or the new JS explode method. Both however have undesired side effects.
With a remove method it will also become possible to selectively remove subentities and replace them with normal entities on the same spot.
With the current explode method you already can selectively explode subentities away. That means just a copy of this current method without the explosion itself would be sufficient.
With a remove method it will also become possible to selectively remove subentities and replace them with normal entities on the same spot.
With the current explode method you already can selectively explode subentities away. That means just a copy of this current method without the explosion itself would be sufficient.
UPS-Courier & DeepSpacePirates & others at the box and some older versions
A js work around could beEric Walch wrote:
With the current explode method you already can selectively explode subentities away. That means just a copy of this current method without the explosion itself would be sufficient.
Code: Select all
subentity = ship.subEntitties[x]
subentity.setPosition(0,0,15000000)
subentity.explode()
of course a ship.remove() would be more clean..
so i second that...
Bounty Scanner
Number 935
Number 935
- Eric Walch
- Slightly Grand Rear Admiral
- Posts: 5536
- Joined: Sat Jun 16, 2007 3:48 pm
- Location: Netherlands
I know, it can even be more complex. Currently I move my copy to deep space, explode the subents away that are also missing on the original and than move it over the original and as last I move the original to deep space. With just a single remove option it would be a lot easier.Frame wrote:A js work around could be
Code: Select all
this.removeSubs = function()
{
let subPresent = false
for(let i=0;i<this.reverseShip.subEntities.length;i++)
{
subPresent = false
for(let j=0;j<this.ship.subEntities.length;j++)
{
let Org = this.ship.subEntities[j].position
let Copy = this.reverseShip.subEntities[i].position
if(Copy.x == -Org.x && Copy.y == Org.y && Copy.z == -Org.z) subPresent = true
// Ships copy is rotated over the y-axis. x and z position are inverted!
}
if(!subPresent) this.reverseShip.subEntities[i].explode()
}
}
UPS-Courier & DeepSpacePirates & others at the box and some older versions