Author Topic: [MOD] MoveUI Plugin - Sector Ship Notifier (UI shows all ships in sector!)  (Read 4404 times)

Bix

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    18
    • View Profile
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 ?



Shrooblord

  • Hero Member
  • *****
  • Status:
    Offline
    Posts:
    578
    • View Profile
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
Shrooblord



Bix

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    18
    • View Profile


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
« Last Edit: July 26, 2018, 10:24:16 AM by Bix »



Shrooblord

  • Hero Member
  • *****
  • Status:
    Offline
    Posts:
    578
    • View Profile
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.
« Last Edit: July 26, 2018, 11:01:24 AM by Shrooblord »
Shrooblord



Bix

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    18
    • View Profile
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.



Shrooblord

  • Hero Member
  • *****
  • Status:
    Offline
    Posts:
    578
    • View Profile
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.
Shrooblord



Bix

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    18
    • View Profile
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
« Last Edit: July 26, 2018, 02:52:23 PM by Bix »



Rilgar

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    6
    • View Profile
@Bix - Sounds like some great changes. Would be great if you could upload zip of your updates :)



Bix

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    18
    • View Profile
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



Shrooblord

  • Hero Member
  • *****
  • Status:
    Offline
    Posts:
    578
    • View Profile
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.
Shrooblord



Shrooblord

  • Hero Member
  • *****
  • Status:
    Offline
    Posts:
    578
    • View Profile
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.
Shrooblord



Dirtyredz

  • Full Member
  • ***
  • Status:
    Offline
    Posts:
    225
  • David McClain - Dirtyredz
    • View Profile
    • Dirtyredz.com
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)
David McClain - Dirtyredz
Programmer, Web Development, Modder
http://www.Dirtyredz.com




Halfton

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    12
    • View Profile
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?



Neogenesis

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    1
    • View Profile
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  ::)



Taurec

  • Newbie
  • *
  • Status:
    Offline
    Posts:
    9
    • View Profile
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.