Avorion Forum

General => Mods => Topic started by: DracoNB on May 22, 2018, 10:36:57 AM

Title: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: DracoNB on May 22, 2018, 10:36:57 AM
Features:


Pre-Reqs: MoveUI by Dirtyredz (v2.1.1) (http://www.avorion.net/forum/index.php/topic,3834.30.html)
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:

Code: [Select]
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
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Ditsydoo on June 09, 2018, 02:16:54 PM
This is pretty sweet, now if only I can get the AI to target the enemy I target.
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Galovist on June 09, 2018, 08:20:55 PM
 ;D Love this mod, so much less delegating small tasks and so much more winning.
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Shrooblord on July 11, 2018, 11:16:14 PM
Ah geebus this is good. Thank you thank you thank you!
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: DracoNB on July 12, 2018, 06:50:38 AM
Ah geebus this is good. Thank you thank you thank you!

Glad you like it, glad its still working for the latest patch I haven't played much myself recently
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Shrooblord on July 12, 2018, 06:54:34 PM
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.
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Devious on July 12, 2018, 06:58:45 PM
Awesome, nice to see others joining in on extending MoveUI :)
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Devious on July 12, 2018, 06:59:53 PM
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 :)
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Shrooblord on July 12, 2018, 07:21:21 PM
Additionally, I added alphabetical sorting to the list (by ship name) and a tiny tweak to the colours that were used to display the names. My friend and I found the deep purple very hard to read so I made it slightly more pastel.
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Shrooblord on July 12, 2018, 10:20:54 PM
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.
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Bix on July 17, 2018, 08:53:32 PM
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 :
Code: [Select]
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 !

Code: [Select]
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
(http://tinyurl.com/yb53jfm8)
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Delerium76 on July 18, 2018, 12:59:25 AM
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 :
Code: [Select]
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 !

Code: [Select]
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
(http://tinyurl.com/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"
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: DracoNB on July 18, 2018, 01:00:55 AM
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.
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Bix on July 18, 2018, 06:15:42 AM
Mhhh I tried your copy/paste method, but I think I broke everything ^^

-> https://pastebin.com/k494xDfx

The checkboxes are working, or displayed at least, I also have no error in server console, but there's nothing displayed on the UI...

Do someone have hints ?
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: DracoNB on July 18, 2018, 10:56:59 PM
Mhhh I tried your copy/paste method, but I think I broke everything ^^

-> https://pastebin.com/k494xDfx

The checkboxes are working, or displayed at least, I also have no error in server console, but there's nothing displayed on the UI...

Do someone have hints ?

You'll need to rename any "ShipNotifier" to "StationNotifier" or similar :)
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Bix on July 24, 2018, 02:42:29 PM
Is there a way to show Alliance relations instead of player relations ?

Code: [Select]
local relation = playerFaction:getRelations(factionIndex)
Something to change here I think ?
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Shrooblord on July 25, 2018, 03:27:28 PM
The following code determines a player's faction, or, if they're piloting an Alliance ship, their Alliance's faction:
Code: [Select]
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
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Bix on July 26, 2018, 10:20:42 AM
(http://tinyurl.com/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 ^^:

Code: [Select]
    local faction = player or player.allianceIndex
    local playerFaction = Faction()

Code: [Select]
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
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Shrooblord on July 26, 2018, 10:59:35 AM
Ahhhhhh herp-dee-derp my bad!!

This script is already executed exclusively client-side, yes? In that case,
Code: [Select]
local player = Player().indexis 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:

Code: [Select]
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:

Code: [Select]
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.
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Bix on July 26, 2018, 11:58:03 AM
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.
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Shrooblord on July 26, 2018, 12:22:19 PM
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.
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Bix on July 26, 2018, 12:55:53 PM
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 ^^'

Code: [Select]
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
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Rilgar on July 26, 2018, 11:34:36 PM
@Bix - Sounds like some great changes. Would be great if you could upload zip of your updates :)
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Bix on July 27, 2018, 05:51:02 PM
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
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Shrooblord on January 03, 2019, 08:35:26 PM
I've included Bix's changes, my own changes, and made the mod Beta Branch 0.20.2-compliant, so it now uses proper "callable" functionality.

I have reverted the colours back to what I like though......  ;D

Installation instructions are the same as on the first post of this topic.
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Shrooblord on January 05, 2019, 02:05:11 AM
I just did a big derp. I forgot part of what made my own modifications work in the first place. Updated that now. Version 1.4 is here to greet you.

The "[!]" symbol and all changes mentioned above are now Beta Branch 0.20.2 compliant. This mod replaces /entity/bulletinboard.lua, so will clash with other mods that modify that script.

bulletinboard.lua needs to be installed both client- and serverside.
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Dirtyredz on January 15, 2019, 08:50:52 PM
Wow, this is amazing. Its nice knowing someone has made a great looking UI using my Mod.
Great Work!! Looking forward to more UI's

(dang this means i need to make sure the MoveUi mod is always up to date lol)
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Halfton on March 11, 2019, 03:51:59 PM
I am having a little difficulty with this mod.  I have MOVEUI installed and configured and it appears to be working as it should.  I have installed ShipNotifier as described.  When I restart Avorion, I can fond the ShipNotifier on/off checkbox on the main page of the MOVEUI setup dialogue and I have also located the ShipNotifier configuration page.  Selecting the "Show Friendlies" checkbox and turning on the function on the main MOVEUI page, I can see the outline of the ShipNotifier box, but when I click to display the actual info, I see nothing there.  This is in a sector with many friendlies (I am admired here), plus two of my other ships. 

I am on Beta 21.2.  Does anyone have any suggestions as to what I can do to rectify this?
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Neogenesis on April 05, 2019, 10:44:04 PM
Hi,

I installed it on the server and client.

But i got this Error:

Eat-My-Shorts: mods/MoveUI/scripts/player/ShipNotifier.lua: Function 'detect' is
 uncallable from remote. To call it from remote, enter it into the 'Callable' ta
ble with 'callable(...).'


What can i do?
I running the latest Version on both.


Sorry for my bad english  ::)
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Taurec on April 26, 2019, 06:27:31 PM
I am having a little difficulty with this mod.  I have MOVEUI installed and configured and it appears to be working as it should.  I have installed ShipNotifier as described.  When I restart Avorion, I can fond the ShipNotifier on/off checkbox on the main page of the MOVEUI setup dialogue and I have also located the ShipNotifier configuration page.  Selecting the "Show Friendlies" checkbox and turning on the function on the main MOVEUI page, I can see the outline of the ShipNotifier box, but when I click to display the actual info, I see nothing there.  This is in a sector with many friendlies (I am admired here), plus two of my other ships. 

I am on Beta 21.2.  Does anyone have any suggestions as to what I can do to rectify this?

I have the same Problem with Game Version 21.4.
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Halfton on May 05, 2019, 03:39:34 PM
Looking at the game log, I am getting a lot of these errors:

xxxxxxxx: mods/MoveUI/scripts/player/ShipNotifier.lua: Function 'detect' is uncallable from remote. To call it from remote, enter it into the 'Callable' table with 'callable(...).'

I guess this is why the mod is not working for me.  Have I done something wrong in setup?  Does there need to be an update for the newer Beta versions?  Anyone with any Lua knowledge know how to put this right?

Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Rinart73 on May 05, 2019, 04:19:33 PM
Does there need to be an update for the newer Beta versions?
Anyone with any Lua knowledge know how to put this right?
Yes and yes. I can help but a bit later  :)

Here you go - updated to 0.21.x
Title: Re: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)
Post by: Halfton on May 05, 2019, 05:06:20 PM
Thank you so much for your help.  It works a treat now! 
Best Regards
Andy.