Page 2 of 3

Posted: Wed Aug 20, 2008 10:15 pm
by Captain Hesperus
TGHC wrote:
Just a thought.......would it be possible to link suitable audio messages to the type of missile as part of a custom sounds type OXP? or within the missile analyser OXP?
Like "Oh, look. Soft top (unHardened Missile) incoming... when are you wanting to ECM?"
or
"Holy Giles!!! Incoming Q-missile!"

Captain Hesperus

Posted: Thu Aug 21, 2008 7:29 pm
by Frame
TGHC wrote:
Just a thought.......would it be possible to link suitable audio messages to the type of missile as part of a custom sounds type OXP? or within the missile analyser OXP?
When the next release of oolite is out then 100% Yes.

it is allready possible,, but it is in a cheating kind of way, by using some functions that are meant to play music... however, it also means, that any music played will be stopped and that overlapping messages will cutoff each other, since only one track can be played at any one time...

it would prolly work similar to the hyper-radio config file setup...

Posted: Fri Aug 22, 2008 9:06 pm
by JensAyton
Frame wrote:
When the next release of oolite is out then 100% Yes.

it is allready possible,, but it is in a cheating kind of way, by using some functions that are meant to play music...
I’ve said this before, so I may as well say it again: full JavaScript sound support is in 1.71, as sort-of-documented in the Progress thread.

Posted: Tue Nov 04, 2008 4:03 pm
by Eric Walch
This is my first oxp to be adapted to Oolite 1.72 The current version is still functional with Oolite 1.72 but writes warnings to the log about changed names.

For this version I added a remove equipment option. Now you can remove the analyser at systems of the same technical level as where you bought it. For this equipment not very useful as you can also just remove the oxp itself when you want the Missile Analyser to disappear. But it is example code how to remove equipment with the new handler in Oolite 1.72

Missile Analyser 1.1

Posted: Thu Nov 06, 2008 6:45 am
by Commander McLane
Hey, that's cool. So now one could script the option to re-sell all the equipment. Let's see if I get ten minutes time today... :wink:

Posted: Thu Nov 06, 2008 10:06 am
by Commander McLane
Got my ten minutes. :D

Okay, actually it took me a little more time to figure out that playerBoughtEquipment isn't fired when the equipment costs 0 (would like to get an explanation for that behaviour; is the handler somehow bound to player.credits)?

The bad news is (for the Missile Analyser as well, I'm afraid) that the refund isn't paid. Perhaps the internal routine that decreases player.credits when you buy something, gets in the way of the player.credits += whatever in the script?

Posted: Thu Nov 06, 2008 10:21 am
by another_commander
Commander McLane wrote:
Okay, actually it took me a little more time to figure out that playerBoughtEquipment isn't fired when the equipment costs 0 (would like to get an explanation for that behaviour; is the handler somehow bound to player.credits)?
Explanation: If the credits before you buy equipment are equal to the credits after you've bought it (this is effectively how it is written in the code that the equipment you try to buy costs 0 Cr), then Oolite does not do anything (well, it does play the boop.ogg soundfile). The event handler is fired only if your credits amount has changed after the transaction. I think it makes sense this way. This is how Oolite has always treated equipment buying. But it would be very easy to change it so that a zero credit transaction is considered buying and have the handler firing anyway.

Posted: Thu Nov 06, 2008 10:31 am
by Commander McLane
It's not true that Oolite doesn't do anything. Specifically, the equipment that costs 0 cr does disappear from the F3-screen and appear one the F5-screen. So the transaction is actually made. Only the handler doesn't fire.

Any idea on the other problem, that the financial transaction within the handler is ignored? Eric's code is like this

Code: Select all

this.playerBoughtEquipment = function(equipment)
{
    if(equipment == "EQ_MISSILE_ANALYSER_REMOVER")
    {
        player.ship.removeEquipment("EQ_MISSILE_ANALYSER")
        player.ship.removeEquipment("EQ_MISSILE_ANALYSER_REMOVER")
        player.credits += 14000
    }
}
and mine very similar (of course), but the player.credits += 14000 is not executed.

By the way, Eric: The equipment description mentions a refund of 15000, not 14000.

Posted: Thu Nov 06, 2008 10:42 am
by another_commander
Commander McLane wrote:
It's not true that Oolite doesn't do anything. Specifically, the equipment that costs 0 cr does disappear from the F3-screen and appear one the F5-screen. So the transaction is actually made. Only the handler doesn't fire.
Yes, the transaction appears to be happening, but at the end it is not considered as done. You will note that the boop sound does play. I think you are right, though, after a very quick check, it does look like a bug.

Posted: Thu Nov 06, 2008 10:52 am
by Commander McLane
I play with sound off, so I didn't notice. And in the end I left the station with all my equipment and a whole lot of "Sell foo"-equipment items in my inventory.

And for the other issue: Never mind. I found out that the refund is actually paid. It just doesn't appear in the line stating your credits on top of the screen. The costs of the item, however, do appear. (Credits are decremented, but not increased. So you have to switch to another screen before you see the refund on your account.

It would be nice, however, if something could be done to change this. For instance, in the end of the playerBoughtEquipment-routine there could be a command to redraw the current screen, updating all the changes made by the various scripts that use playerBoughtEquipment. Is that doable?

Posted: Thu Nov 06, 2008 11:32 am
by Eric Walch
Commander McLane wrote:
and mine very similar (of course), but the player.credits += 14000 is not executed.
By the way, Eric: The equipment description mentions a refund of 15000, not 14000.
My mistake not to check if credits were actually raised. I just checked if the equipment was added/removed at the right way.

The value was my mistake. I changed it from 14000 to 15000 but forgot to change it at both places.
That it is not working with 0 credits I didn't try. I just ask 20 credits for removal (Is handled by oolite) and award the 14000 cr by script.
I noticed that oolite also asked 20 credits for missile removal and assumed it is not foreseen to have 0 cr equipment.

What I did notice is that when equipment becomes available by the handler it is not shown on the screen. Switching back/for to an other screen solves this.

Posted: Thu Nov 06, 2008 11:33 am
by another_commander
The playerBoughtEquipment handler now fires even if the price of the equipment bought is 0.

Posted: Thu Nov 06, 2008 12:25 pm
by Commander McLane
Eric Walch wrote:
What I did notice is that when equipment becomes available by the handler it is not shown on the screen. Switching back/for to an other screen solves this.
Yes. If you buy a missile analyser, the removal option as added instantly. However, if you buy the removal, the missile analyser is not added until you switch screens. That's true for my equipment-removals as well.

Therefore my question whether it is possible to modify the handler itself in a way that after all scripts are executed, the screen is drawn again (which is more or less how the internal equipment-buying works, I guess). Possible?

Posted: Thu Nov 06, 2008 1:11 pm
by Svengali
Commander McLane wrote:
Eric Walch wrote:
What I did notice is that when equipment becomes available by the handler it is not shown on the screen. Switching back/for to an other screen solves this.
Yes. If you buy a missile analyser, the removal option as added instantly. However, if you buy the removal, the missile analyser is not added until you switch screens. That's true for my equipment-removals as well.

Therefore my question whether it is possible to modify the handler itself in a way that after all scripts are executed, the screen is drawn again (which is more or less how the internal equipment-buying works, I guess). Possible?
Maybe it would be better to implement a equivalent function in JS to the legacy setGuiToxyzScreen so the script could use it after doing all other things. This would also be useful for Eric's UPS and for my coming Vector.

Posted: Thu Nov 06, 2008 1:12 pm
by Eric Walch
Commander McLane wrote:
Therefore my question whether it is possible to modify the handler itself in a way that after all scripts are executed, the screen is drawn again (which is more or less how the internal equipment-buying works, I guess). Possible?
Yes, it is not updating everything now. But nobody who just has sold something wants to buy it back immediately, so there is no real problem. That the credits are not updated on the same screen is a little more noticeable.

On my bug with the wrong refund: I uploaded a new version 1.1.1 were you do get 15000 credits back as promised in the equipment description. (and not 14000. We poor salesmen. When we try to earn an additional 100 credits, customers immediately notice nowadays.)