Jump to content

Welcome to the Forum!

The best place to exchange builds and ideas! Vote for the best ideas and suggestions here.

Join the Avorion Discord!

Connect with other passionate players and talk about the latest news.
Discord

DLC Avorion Into the Rift Out Now!

Now available on Steam!
Steam

[MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)


DracoNB
 Share

Recommended Posts

Features:

 

  • Shows all ships in sector
  • Filter out Civilian and/or Friendly ships
  • Select ship by left or right clicking on the list (Warning, left mouse WILL fire weapons!) I recommend using right click.
  • Choose faction relation level to consider "friendly"

 

Pre-Reqs: MoveUI by Dirtyredz (v2.1.1)

Server side requirements: Yes

 

Client side requirements: Yes

 

Install:

 

Download the file. Unzip "ShipNotifier.lua" to your avorion/mods/MoveUI/Scripts/player folder

 

Edit avorion/mods/MoveUI/config/MoveUIConfig.lua and add the following down with the others:

 

MoveUIConfig.AddUI("ShipNotifier", false)

 

Where you add it is where it will show up on the main MoveUI screen. I personally put it under "FactionNotifier" since that deals with adding sector faction info and this adds the ship details.

 

Here is an example video of it in action:

 

 

Download:

 

https://github.com/draconb/avorion-shipnotifier/releases

 

Download the source code and then unzip the mods folder to your steamapps\common\avorion\mods

 

Should look like:

 

steamapps\common\avorion\mods\MoveUI\scripts\player\ShipNotifier.lua

 

and have a few other files from MoveUI already in that folder such as FactionNotifier.lua. If you don't, its in the wrong spot!

 

TODO:

 

Figure out if there is a way to cancel mouse button events so middle mouse button can be used for target selection (it selects then deselects since the mouse isn't over a target)

 

More options?

 

Improve contrast? Hard to see depending on the sector / lighting. I added a slight drop shadow to help

Link to comment
Share on other sites

  • 3 weeks later...
  • 1 month later...

My friend wanted to be able to select Stations in the same way you can select ships. I basically hacked together that functionality by lazily copy-pasting what was already in-place for ships. Not super sure if it's buggy, but it seemed to work fine for us, so give it a try if that sounds interesting to you!

 

Exact same installation instructions; see the first post.

avorion-shipnotifier-1.0_withStations.zip

Link to comment
Share on other sites

My friend wanted to be able to select Stations in the same way you can select ships. I basically hacked together that functionality by lazily copy-pasting what was already in-place for ships. Not super sure if it's buggy, but it seemed to work fine for us, so give it a try if that sounds interesting to you!

 

Exact same installation instructions; see the first post.

 

Interesting, that's one less click than using Sector Overview :)

Link to comment
Share on other sites

One more from me.

 

My friend wanted to know if I could add a "[!]" in front of the Stations' names for Stations that have a Bulletin active on their Bulletin Board, so you can in one glance see whether there are Bulletins available when you jump into a Sector.

 

The result is the attached file.

 

It includes all the previous changes, but now also overwrites the vanilla file data/scripts/entity/bulletinboard.lua. Will conflict with other mods that overwrite the same file.

 

Drag and drop the contents into your main Avorion folder.

 

----

 

EDIT:

 

And a bug report: the Persecutor Pirate teams that get spawned on you when you're weak in a certain part of the Galaxy are mislabelled as "Friendly Ships", even though relations with them are Abhorrent, with the "Friendly Threshold" set at 0.

 

 

----

 

Bug Report #2:

 

While piloting a Faction ship, the relations displayed are those of the ships towards the PLAYER, not towards the Faction. This is confusing behaviour.

avorion-shipnotifier-1.0_withStations_alphabetically_bulletins.zip

Link to comment
Share on other sites

Thanks for this mod, really, this is my number one favorite !

 

One thing bother me thought, the alphabetic sorting, it's either on the ship.name and not useful at all (for me) or on the ship.title and then can flicker if there's two or more from the same type.

Is it possible to sort by title and/then by name ?

 

a bit like this :

		local sort_func = function( a,b ) return a.title.name < b.title.name end
	table.sort(ShipData.Ships, sort_func)

 

But I don't think it would work, I have zero knowledge in coding.

 

 

edit :

 

OK ! I've found with some search !

 

		local sort_func = function( a,b ) return (a.title < b.title) or (a.title == b.title and a.name < b.name) end
	table.sort(ShipData.Ships, sort_func)

 

Now everything is fine :D

yb53jfm8

Link to comment
Share on other sites

Thanks for this mod, really, this is my number one favorite !

 

One thing bother me thought, the alphabetic sorting, it's either on the ship.name and not useful at all (for me) or on the ship.title and then can flicker if there's two or more from the same type.

Is it possible to sort by title and/then by name ?

 

a bit like this :

		local sort_func = function( a,b ) return a.title.name < b.title.name end
	table.sort(ShipData.Ships, sort_func)

 

But I don't think it would work, I have zero knowledge in coding.

 

 

edit :

 

OK ! I've found with some search !

 

		local sort_func = function( a,b ) return (a.title < b.title) or (a.title == b.title and a.name < b.name) end
	table.sort(ShipData.Ships, sort_func)

 

Now everything is fine :D

yb53jfm8

 

Looks great, but it would be nice if the stations were separated out with their own heading, like it does in the original mod with "Friendly ships" and "Civilian ships"

Link to comment
Share on other sites

One more from me.

 

My friend wanted to know if I could add a "[!]" in front of the Stations' names for Stations that have a Bulletin active on their Bulletin Board, so you can in one glance see whether there are Bulletins available when you jump into a Sector.

 

The result is the attached file.

 

It includes all the previous changes, but now also overwrites the vanilla file data/scripts/entity/bulletinboard.lua. Will conflict with other mods that overwrite the same file.

 

Drag and drop the contents into your main Avorion folder.

 

----

 

EDIT:

 

And a bug report: the Persecutor Pirate teams that get spawned on you when you're weak in a certain part of the Galaxy are mislabelled as "Friendly Ships", even though relations with them are Abhorrent, with the "Friendly Threshold" set at 0.

 

 

----

 

Bug Report #2:

 

While piloting a Faction ship, the relations displayed are those of the ships towards the PLAYER, not towards the Faction. This is confusing behaviour.

 

Hah, I was actually going to make the stations one separate since the list can already get quite big. You could basically copy/paste the code and rename to it stations everywhere so that way you can place them in two locations and enable/disable as wanted. And yeah I noticed the Player not Faction coloring which is annoying. Meant to fix it but haven't been playing recently.

Link to comment
Share on other sites

The following code determines a player's faction, or, if they're piloting an Alliance ship, their Alliance's faction:

local faction = player or player.allianceIndex

 

You may or may not have to attach a .index to faction in order to get it to work in the line of code you posted. Not sure. Haven't tried myself.

 

Also, could you provide a .zip with your changes when you're done? :)

 

EDIT: Hero Member post! yay level up

Link to comment
Share on other sites

ybqybw8q

 

As I said I have zero knowledge, what I did is to put your code just before the first local with "faction()" in it ^^:

 

    local faction = player or player.allianceIndex
    local playerFaction = Faction()

 

function ShipNotifier.detect()
    if onClient() then
        invokeServerFunction('detect')
        return
    end

    local ships = {Sector():getEntitiesByType(EntityType.Ship)}
local stations = {Sector():getEntitiesByType(EntityType.Station)}

    local faction = player or player.allianceIndex
    local playerFaction = Faction()

    ShipData = {}
    ShipData.Ships = {}

    for _, ship in pairs(ships) do
        local index = ship.index
        local name = ship.name
        local title = ship.translatedTitle
        local factionIndex = ship.factionIndex
        local civilship = ship:hasScript("civilship.lua")
        local relation = playerFaction:getRelations(factionIndex)
        
        local bulletin = ship:getValue("hasBulletin")
        
        if bulletin == 1 then
            bulletin = "[!] "
        else
            bulletin = ""
        end
        
        --print (tostring(name) .. " | " .. tostring(title) .. " | " .. tostring(factionIndex) .. " | " .. tostring(civilship) .. " | " .. tostring(relation))
        local shipData = {index = index, name = name, title = title, factionIndex = factionIndex, civilship = civilship, relation = relation, bulletin = bulletin}
        table.insert(ShipData.Ships, shipData)
    end

for _, station in pairs(stations) do
        local index = station.index
        local name = station.name
        local title = station.translatedTitle
        local factionIndex = station.factionIndex
        local civilship = station:hasScript("civilship.lua")
        local relation = playerFaction:getRelations(factionIndex)
        
        local bulletin = station:getValue("hasBulletin")
        
        if bulletin == 1 then
            bulletin = "[!]"
        else
            bulletin = ""
        end
        
        --print (tostring(name) .. " | " .. tostring(title) .. " | " .. tostring(factionIndex) .. " | " .. tostring(civilship) .. " | " .. tostring(relation))
        local shipData = {index = index, name = name, title = title, factionIndex = factionIndex, civilship = civilship, relation = relation, bulletin = bulletin}
        table.insert(ShipData.Ships, shipData)
    end

    ShipNotifier.sync()
end

Link to comment
Share on other sites

Ahhhhhh herp-dee-derp my bad!!

 

This script is already executed exclusively client-side, yes? In that case,

local player = Player().index

is required first. This will store the actual player index into the local variable I told you to use earlier......... xD sorry

 

====

EDIT:

NEVERMIND. Do this:

 

function ShipNotifier.detect(playerIndex)
    if onClient() then
        invokeServerFunction('detect', playerIndex)
        return
    end
    
    local player = Player(playerIndex)
    (...)
end

====

 

You'll need to retrieve the Faction similarly. For example:

 

Faction(player.craft.factionIndex)

 

You may be wondering why you need to use the .index to determine the actual Faction. This is because Faction is like an object of sorts, an Entity, almost, and the index is like a UUID pointing to a specific Faction. You can't execute code on an "id" alone; you need to execute it on an actual, valid "object". So you need to "cast" the UUID into a Faction "object" in order for the code to know what you're referring to.

Link to comment
Share on other sites

Niiiiiice ! It seems to work almost perfectly, almost because in one sector the trading post isn't showing up in the list. I will investigate on this.

Besides this one, it's fine and the list is updated as soon as the alliance craft is left/boarded !

 

Now I just need to modify colors a bit, I don't like the current behaviour. I'll try to mimic default target's frames colors.

Link to comment
Share on other sites

Now I just need to modify colors a bit, I don't like the current behaviour. I'll try to mimic default target's frames colors.
Did you base your code off of my code? I did mention I modified the colours to make them more readable, as the deep purples the mod originally used were incredibly hard to read against the dark background of space. You can simply check what the original mod used if you're not happy with the colours.
Link to comment
Share on other sites

Yes I did, but I'd really prefer to get the same color pattern as the vanilla. Red, orange, yellow, purple, blue, green.

 

I know it's not the best for readability but that's faster to spot the different factions.

 

edit : Since the most of color gradiants are between -10 000 and 10 000, I think it's not possible to do so as the code is setting colors by steps of 10 000, if I understand ^^'

 

function GetRelationColor(relation)
    for _, RC in pairs(RelationColors) do
        local result = RC.Relation - relation
        --print(RC.Relation,relation,math.abs(result))
        if math.abs(result) < 10000 then
            return RC.R, RC.G, RC.B
        end
    end
end

ShipNotifier.lua.xml

Link to comment
Share on other sites

I've uploaded the file above your post, just erase the original one with mine (remove the .xml at the end, couldn't upload a .lua file)

 

But keep in mind I didn't changed the colors the way I wanted, I just don't know how to do so :/ I'm still investifating

Link to comment
Share on other sites

  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...