Missile Analyser.oxp

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

Moderators: winston, another_commander

User avatar
Captain Hesperus
Grand High Clock-Tower Poobah
Grand High Clock-Tower Poobah
Posts: 2310
Joined: Tue Sep 19, 2006 1:10 pm
Location: Anywhere I can sell Trumbles.....

Post 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
The truth, revealed!!
Image
User avatar
Frame
---- E L I T E ----
---- E L I T E ----
Posts: 1477
Joined: Fri Mar 30, 2007 8:32 am
Location: Witchspace

Post 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...
Bounty Scanner
Number 935
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post 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.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post 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
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:

Post 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:
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:

Post 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?
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

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

Post 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.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

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

Post 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?
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

Post 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.
Last edited by Eric Walch on Thu Nov 06, 2008 11:37 am, edited 1 time in total.
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Post by another_commander »

The playerBoughtEquipment handler now fires even if the price of the equipment bought is 0.
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:

Post 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?
User avatar
Svengali
Commander
Commander
Posts: 2370
Joined: Sat Oct 20, 2007 2:52 pm

Post 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.
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

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