ConsoleMessage acting unwanted

For test results, bug reports, announcements of new builds etc.

Moderators: winston, another_commander, Getafix

Post Reply
User avatar
Eric Walch
Slightly Grand Rear Admiral
Slightly Grand Rear Admiral
Posts: 5536
Joined: Sat Jun 16, 2007 3:48 pm
Location: Netherlands

ConsoleMessage acting unwanted

Post by Eric Walch »

I noticed that commsMessage and consoleMessage3s works different if executed by a NPC ship. It is a bug or not?

To set things in context: I have installed Cargo_wreck_teaser 1.2.1 That OXP replaces the default cargopods by a large variety new ones. Some have a script_actions script. It awards the cargo and uses a commsMessage to say what is added. Those messages however are logged. I switched those commands for a consoleMessage3s command. Now I sometimes see at random those massages on the console, even when docked. I noticed them under 1.69.1 and but probably also happens under 1.65
I also used those consoleMessages for cargo scooping in my own OXP. I probaly have to change them back to commsMessages in a future release.

This must be caused by NPC ships scavenging those cargopods and activating the script. The commsMessage is suppressed when issued by a NPC ship but the consoleMessage3s clearly not. Is this intentional, or a omission.

In my opinion must a console message go to the console of the acting ship. If this is a NPC ship, the player should not see them.
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 »

The legacy scripting system was not designed with the ability to target non-player ships in mind. The JavaScript model is, and in the next release it will be possible to do this with a ship script with a wasScooped event handler:

Code: Select all

this.wasScooped = function(scooper)
{
    if (scooper.isPlayer)
    {
        // No JavaScript equivalent to consoleMessage3s yet.
        scooper.call("consoleMessage3s:", "Message")
    }
}
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 »

Ahruman wrote:
The legacy scripting system was not designed with the ability to target non-player ships in mind.
That is ok, but if I saw it right, some legacy script commands in oolite explicit checks if the target is the player like the awardCargo or awardCredits commands. So nothing happens in those cases.
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 »

OK, lets call it a feature instead of a bug. Looking in the source-code I just noticed that the commands

awardCredits:
awardShipKills:
awardEquipment:
removeEquipment:
awardCargo:
removeAllCargo

are explicit coded to not react if not acting on a player. That means they do nothing in a death_actions and do nothing in an actions_script if scooped by a NPC ship. Thus above commands only work in an actions_script if scooped by the player.

I would have expected that consoleMessage3s, addFuel and some others would also be excluded the same way.

But if you can not fight the enemy you should join him, is an old wisdom. So I turned it into a feature. After a bit puzzling I found a way to distinguish if a barrel was scooped by the player or a NPC ship. Now I am writing a small mission for the courier.OXP were the player must scoop barrels in competition of several NPC ships. They are both independently counted and when the NPC ship scoops one, the player sees: "NPC ship scooped barrel nr X", just to let the player know he has to hurry and the player now knows when all barrels are scooped.

Working on this I realized that there exist several OXP's with fuelpods in them. They all must have the same bug. addFuel or setFuelLeak also work if an NPC ship scoops the barrel. That means the player gets the fuel or is punished with a fuelLeak even if he is not the one that scoops the fuelpod. This could for example happen with the Cargo_Wreck_Teaser.OXP. It is however rear as I have not met a fuelLeak caused by this OXP by this way.

As this behavior is badly documented I added a wiki page on this subject.

Scripts within Shipdata

I linked it from within the shipdata.plist page and the script category. If anyone can add to it, please change it or let me know. There can only be good scripts if the documentation is good.
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 awardFuel and setFuelLeak legacy script command code has been changed in the SVN repository to act on the entity targeted by the script, instead of always the player.

There seems to be something wrong with commsMessage at the moment. Messages are printed on the screen even if the script is not targetting the player. It is under investigation, hopefully will be resolved soon.
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 »

At least as far as AI-methods are concerned there is a difference between commsMessage and sendTargetCommsMessage. The latter goes to the target only, so should be visible on the player's screen only when his ship is targetted. The former is visible for everyone in range. At least that's how it should work according to the wiki.

As far as script-methods are concerned, there is only the former, so the player sees everything on his screen that is brought up by a script using commsMessage.

A solution could therefore be to move messaging into an AI, using sendTargetCommsMessage only. Problem is, this is not a substitute for anything sent by the shipdata in death_actions.
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1876
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

@EW: It was my intention to have the pods generate console messages, and only when the player scooped one.
Due to some peculiarities in how cargo is hardcoded, no automatic console message was generated by custom pods. I decided to turn this into a minor feature with the specialty foods.
At the time, only commsMessage was available, so I made do with that.

Now that consoleMessage is available, I will switch to that immediately.
CommsMessage should be triggered by NPC as well, however it is only 'recieved' by entities inside a certain range. Console message being triggered by NPCs is just wrong. If this is confirmed, changing the range of these messages to say 50m should fix this problem. Or just have it act on player only naturally. (Though there may be some applications where you'd wan't an NPC action to trigger a console message.)
Riding the Rocket!
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 »

By the way, E_W: Could you give some more information to us normal people about consoleMessage3s or consoleMessages or whatever it is called (or are these two distinct methods?).

When was it introduced? Where is it probably documented (apart from this thread)? What exactly does it do? What kind of method is it anyway (script, AI)?

I am just asking because prior to this thread I have never ever heard of it.

I know that there may be a couple of undocumented methods, keys and commands out there, but, please, if you find one, make a proper documentation.

Yours very thankfully!

Commander McLane
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 »

consoleMessage3s: and consoleMessage6s: were added in version 1.63 and are documented (as existing) in the Read Me file. They are script methods which print a message for three or six seconds respectively.

There is also a script method commsMessage:, which is different from the AI method of the same name in that it always puts a message on the player’s comm regardless of distance to the current scripting target.

The as-yet undocumented JavaScript equivalents for future releases are:

Code: Select all

player.consoleMessage("message")
player.consoleMessage("message", 6)
player.commsMessage("message")
(The time argument is optional, defaults to 3 for consoleMessage and 4.5 for commsMessage, and may be anything from 1 to 10 seconds.)
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 »

Thanks for the enlightening, Ahruman!

So am I correct that consoleMessage3s or consoleMessage6s respectively do the same as commsMessage, except the message is not stored in the comms_log and therefore doesn't turn up again on hitting the key_comms_log-key?
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 »

That appears to be the case, yes.
User avatar
Arexack_Heretic
Dangerous Subversive Element
Dangerous Subversive Element
Posts: 1876
Joined: Tue Jun 07, 2005 7:32 pm
Location: [%H] = Earth surface, Lattitude 52°10'58.19"N, longtitude 4°30'0.25"E.
Contact:

Post by Arexack_Heretic »

CommsMessages are visible in the box at the top of the screen and can be reread.
I understood by console message, the same yellow text as generated when scooping a normal pod or switching viewscreen etc.

I never noticed it being introduced way back then...must have been 'away'.
Riding the Rocket!
Post Reply