Jump to content

[Mod] CarrierCommander - continuation of Nexus' Carrier commands


Hammelpilaw

Recommended Posts

CarrierCommander

With CarrierCommander you can send commands to your fighters to salvage, mine or kill enemies.

 

 

This mod moved to another topic:

http://www.avorion.net/forum/index.php/topic,4268.0.html

 

Laserzwei did a lot of changes and compatibility fixes to this mod, before I found the time to do so. This is why I gave this project to him, Im sure it will be maintained very well. Thanks Laserzwei  :)

 

Warning

This mod is currently not compatible with alliance ships. Only use for your own ships!

 

Note

I did not create this mod. It is originally created by Nexus, modified by Dirtyredz and me. Since Nexus seems not to be active in Avorion anymore I wanted to keep his project alive and did a relaunch. For more information watch Authors section below.

 

 

How to use

It only works for launched fighters, so you should set your fighters to defence state, then send commands by the new interface on the right-top side of your screen.

 

You can use one military, and one civil command at the same time. Military fighters will only listen to military commands, civil fighters will only listen to civil commands. That means if you order them to salvage, all launched salvage- and mining-fighter will start to salvage, you should only launch the proper civil fighter for  the current action. Since there are only 3 commands yet you can always use Attack enemies and either Mine or Salvage.

 

 

The Attack enemies command uses priorities to decide, wich enemy should be attacked at first. By default the order from high to low priority is this: ships, wormhole guardian, stations, fighters.

 

You can also decide, if stations and/or fighters should be attacked by this command or being not touched.

 

These settings can be changed in `/mods/CarrierCommander/config/CarrierCommanderConfig.lua`.

 

 

Prerequisites

This mod requires an external resource: ShipScriptLoader

Please follow the installation instructions of ShipScriptLoader before you install CarrierCommander.

 

 

Installation instructions

- Download the mod ShipScriptLoader by Dirtyredz and follow its installation instructions. This is required to load CarrierCommander. If you are already using it you may skip this step.

Note

There is an issue in installation instructions of ShipScriptLoader. These are the lines you should add to server.lua:

local s, b = pcall(require, 'mods/ShipScriptLoader/scripts/server/server')
    if s then if b.onPlayerLogIn then local a = onPlayerLogIn; onPlayerLogIn = function(c) a(c); b.onPlayerLogIn(c); end end end

 

- Open file `Avorion/mods/ShipScriptLoader/config/ShipScriptLoader.lua`

- Before the last line containing `return Config` add this:

Config.Add("mods/CarrierCommander/scripts/entity/CarrierCommander.lua")

- Copy the directory `mods` contained in the CarrierCommander .zip file into the game directory `Avorion`

 

Info

If you have problems to get this mod working please send me a pm and describe whats exactly happening or not happening. Also send me all contents of the files /data/scripts/server/server.lua and /mods/ShipScriptLoader/config/ShipScriptLoader.lua. Only with these informations i could help you to find out whats wrong.

 

 

Authors

- Nexus - creator and original publisher of this mod - thanks for your great work

- Dirtyredz - improved code and moved modfiles into `Avorion/mods` directory

- Hammelpilaw - added the new command `attack enemies` to the mod

 

 

Version history

 

0.3.1

- Fixed an issue in salvaging command

 

0.3.0

- release

Link to comment
Share on other sites

Thanks for keeping mods going!

 

Now, I am using a few different mods so maybe there is something conflicting but I keep getting this error when trying to get my fighters to salvage:

 

2017-10-21 19-57-34| could not execute function 'onCCSButtonPressed' in '"mods/CarrierCommander/scripts/entity/CarrierCommander.lua"':

2017-10-21 19-57-34| mods/CarrierCommander/scripts/entity/CarrierCommander.lua:193: attempt to index global 'fighterTargetingCheckBox' (a nil value)

2017-10-21 19-57-34| stack traceback:

2017-10-21 19-57-34| mods/CarrierCommander/scripts/entity/CarrierCommander.lua:193: in function <mods/CarrierCommander/scripts/entity/CarrierCommander.lua:191>

 

// Lonewolf

Link to comment
Share on other sites

Thanks for keeping mods going!

 

Now, I am using a few different mods so maybe there is something conflicting but I keep getting this error when trying to get my fighters to salvage:

 

2017-10-21 19-57-34| could not execute function 'onCCSButtonPressed' in '"mods/CarrierCommander/scripts/entity/CarrierCommander.lua"':

2017-10-21 19-57-34| mods/CarrierCommander/scripts/entity/CarrierCommander.lua:193: attempt to index global 'fighterTargetingCheckBox' (a nil value)

2017-10-21 19-57-34| stack traceback:

2017-10-21 19-57-34|    mods/CarrierCommander/scripts/entity/CarrierCommander.lua:193: in function <mods/CarrierCommander/scripts/entity/CarrierCommander.lua:191>

 

// Lonewolf

 

This was a bug, sorry. Updated to version 0.3.1 that fixed it.

Link to comment
Share on other sites

Nevermind, turns out I just put the script hook in the wrong place in the loader config.

 

For those having issues. make sure you put Config.Add("mods/CarrierCommander/scripts/entity/CarrierCommander.lua") at the very bottom of the config file. I was putting it mistakingly earlier on in the file which meant that it didn't work.

 

Great mod and thanks for continuing this. It actually makes fighters worthwhile to use, however. any plans to add the feature that Nexus had in his version where the fighters would take their location as the radius when searching for the next target (for mining and salvage) instead of the player ship?

Link to comment
Share on other sites

I can't seem to get the mod working. I have followed the instructions to the letter and yet still no interface. Does this require a new ship to initialise? Also, I have no error messages at all so nothing to indicate what may be wrong.

 

 

Did you install ShipScriptLoader Mod correctly? If you did, please post the contents of following files:

  • Avorion/mods/ShipScriptLoader/config/ShipScriptLoader.lua
  • Avorion/data/scripts/server/server.lua

There may be something wrong. You do not need to build a new ship or change the ship to initialise the mod, ShipScriptLoader fixed that issue.

Link to comment
Share on other sites

Having the same issue

 

ShipScriptLoader.lua

 

local Config = {}
Config.author = 'Dirtyredz'
Config.name = 'Ship Script Loader'
Config.homepage = "https://github.com/dirtyredz/AvorionBoilerPlate"
Config.version = {
    major=1, minor=0, patch = 0,
    string = function()
        return  Config.version.major .. '.' ..
                Config.version.minor .. '.' ..
                Config.version.patch
    end
}

Config.Scripts = {}

function Config.Add(scriptPath)
  table.insert(Config.Scripts,scriptPath)
end

-- Example use to add a script to a players ship
-- Config.Add("mods/YourMod/scripts/entity/YourMod.lua")
Config.Add("mods/CarrierCommander/scripts/entity/CarrierCommander.lua")
return Config

 

server.lua

 

package.path = package.path .. ";data/scripts/lib/?.lua"
package.path = package.path .. ";data/scripts/server/?.lua"
require ("factions")
require ("stringutility")

function onStartUp()
    Server():registerCallback("onPlayerLogIn", "onPlayerLogIn")
    Server():registerCallback("onPlayerLogOff", "onPlayerLogOff")
    Galaxy():registerCallback("onPlayerCreated", "onPlayerCreated")
    Galaxy():registerCallback("onFactionCreated", "onFactionCreated")
end

function onShutDown()

end

function update(timeStep)
    local server = Server()

    local guardianRespawnTime = server:getValue("guardian_respawn_time")
    if guardianRespawnTime then

        guardianRespawnTime = guardianRespawnTime - timeStep;
        if guardianRespawnTime < 0 then
            guardianRespawnTime = nil
        end

        server:setValue("guardian_respawn_time", guardianRespawnTime)
    end

    local serverRuntime = server:getValue("online_time") or 0
    serverRuntime = serverRuntime + timeStep
    server:setValue("online_time", serverRuntime)

end

function onPlayerCreated(index)
    local player = Player(index)
    Server():broadcastChatMessage("Server", 0, "Player %s created!"%_t, player.name)
end

function onFactionCreated(index)

end

function onPlayerLogIn(playerIndex)
    local player = Player(playerIndex)
    Server():broadcastChatMessage("Server", 0, "Player %s joined the galaxy"%_t, player.name)

    player:addScriptOnce("headhunter.lua")
    player:addScriptOnce("eventscheduler.lua")
    player:addScriptOnce("story/spawnswoks.lua")
    player:addScriptOnce("story/spawnai.lua")
    player:addScriptOnce("story/spawnguardian.lua")
    player:addScriptOnce("story/spawnadventurer.lua")
    player:addScriptOnce("player/asteroidMover.lua")                                            --mOS
    matchResources(player)
end

function onPlayerLogOff(playerIndex)
    local player = Player(playerIndex)
    Server():broadcastChatMessage("Server", 0, "Player %s left the galaxy"%_t, player.name)

end
local s, b = pcall(require, 'mods/AvorionBoilerPlate/scripts/server/server')
    if s then if b.onPlayerLogIn then local a = onPlayerLogIn; onPlayerLogIn = function(c) a(c); b.onPlayerLogIn(c); end end end

Link to comment
Share on other sites

There is an issue in installation instructions of ShipScriptLoader mod for server.lua file:

 

local s, b = pcall(require, 'mods/AvorionBoilerPlate/scripts/server/server')

 

this line should instead be like this:

local s, b = pcall(require, 'mods/ShipScriptLoader/scripts/server/server')

 

Then it will work.

Link to comment
Share on other sites

It works great man. but after using it for awhile i notice that i cant issue a command to attack while salvaging when i in drone. my fighter keep on going back in hanger if i go to drone mode.

 

This mod is for ordering the figheters of the ship, you currently control. To control fighter of another ship you should use a ship command, not a carrier command.

Link to comment
Share on other sites

I think so, i did not test it to control fighters of other ships yet. Until this mod can not launch fighters I will not add support for this. But since this works fine using vanilla ship commands it is not really needed  ;)

 

well thnx. the only problem that i encounter is when my main ship die and my fighter keep on attacking other faction that i tried to be good with.

Link to comment
Share on other sites

well thnx. the only problem that i encounter is when my main ship die and my fighter keep on attacking other faction that i tried to be good with.

 

They should stop as soon as their current target dies or despawns. Did not thest this though cause if this does not work it is an Avorion issue.

Link to comment
Share on other sites

 

They should stop as soon as their current target dies or despawns. Did not thest this though cause if this does not work it is an Avorion issue.

 

i thought so too since i tried playing without the mod and the fighter still keeps on attacking the faction that i tried to be good with. my suggestion is it would be nice if theres a shortcut key that can command all ur figther all at once either to attack, salvage, mine or idle since its kinda annoying when u want maximum dmg output using ur fighter but u need to keep on clicking them one by one either to attack the enemy that u highlight or just let them be.

Link to comment
Share on other sites

  • 3 weeks later...

We have much problems with this mod on our server.

if 2 people from 1 alliance in the same sector and uses the fighter, the server spams error messages.

 

I think it is better to rewrite the mod to use the hangar api, and not ask for all fighter in the sector.

Link to comment
Share on other sites

I must be doing something wrong, I can't get the new interface to show up.

 

My Avorion/mods/ShipScriptLoader/config/ShipScriptLoader.lua looks like this

local Config = {}
Config.author = 'Dirtyredz'
Config.name = 'Ship Script Loader'
Config.homepage = "https://github.com/dirtyredz/AvorionBoilerPlate"
Config.version = {
    major=1, minor=0, patch = 0,
    string = function()
        return  Config.version.major .. '.' ..
                Config.version.minor .. '.' ..
                Config.version.patch
    end
}

Config.Scripts = {}

function Config.Add(scriptPath)
  table.insert(Config.Scripts,scriptPath)
end

-- Example use to add a script to a players ship
-- Config.Add("mods/YourMod/scripts/entity/YourMod.lua")
Config.Add("mods/CarrierCommander/scripts/entity/CarrierCommander.lua")
return Config

 

and my Avorion/data/scripts/server/server.lua looks like so

 

package.path = package.path .. ";data/scripts/lib/?.lua"
package.path = package.path .. ";data/scripts/server/?.lua"
require ("factions")
require ("stringutility")

function onStartUp()
    Server():registerCallback("onPlayerLogIn", "onPlayerLogIn")
    Server():registerCallback("onPlayerLogOff", "onPlayerLogOff")
    Galaxy():registerCallback("onPlayerCreated", "onPlayerCreated")
    Galaxy():registerCallback("onFactionCreated", "onFactionCreated")
end

function onShutDown()

end

function update(timeStep)
    local server = Server()

    local guardianRespawnTime = server:getValue("guardian_respawn_time")
    if guardianRespawnTime then

        guardianRespawnTime = guardianRespawnTime - timeStep;
        if guardianRespawnTime < 0 then
            guardianRespawnTime = nil
        end

        server:setValue("guardian_respawn_time", guardianRespawnTime)
    end

    local serverRuntime = server:getValue("online_time") or 0
    serverRuntime = serverRuntime + timeStep
    server:setValue("online_time", serverRuntime)

end

function onPlayerCreated(index)
    local player = Player(index)
    Server():broadcastChatMessage("Server", 0, "Player %s created!"%_t, player.name)
end

function onFactionCreated(index)

end

function onPlayerLogIn(playerIndex)
    local player = Player(playerIndex)
    Server():broadcastChatMessage("Server", 0, "Player %s joined the galaxy"%_t, player.name)

    player:addScriptOnce("headhunter.lua")
    player:addScriptOnce("eventscheduler.lua")
    player:addScriptOnce("story/spawnswoks.lua")
    player:addScriptOnce("story/spawnai.lua")
    player:addScriptOnce("story/spawnguardian.lua")
    player:addScriptOnce("story/spawnadventurer.lua")
    player:addScriptOnce("mods/oosp/scripts/player/oosproduction.lua")                            --oosp
    matchResources(player)
end

function onPlayerLogOff(playerIndex)
    local player = Player(playerIndex)
    Server():broadcastChatMessage("Server", 0, "Player %s left the galaxy"%_t, player.name)
end
local s, b = pcall(require, 'mods/ShipScriptLoader/scripts/server/server')
    if s then if b.onPlayerLogIn then local a = onPlayerLogIn; onPlayerLogIn = function(c) a(c); b.onPlayerLogIn(c); end end end

 

Both of those files appear identical to the functioning examples given previously in this thread. What am I missing? Do I need to initialize this mod or the shipscriptloader in some different way?

Link to comment
Share on other sites

These are no working examples. You have to add this to the very bottom of server.lua:

-- Custom scripts
local s, b = pcall(require, 'mods/ShipScriptLoader/scripts/server/server')
if s then if b.onPlayerLogIn then local a = onPlayerLogIn; onPlayerLogIn = function(c) a(c); b.onPlayerLogIn(c); end end end

Link to comment
Share on other sites

Quick reply, thanks!

 

Still can't get it to work though. I noticed in the mods/ShipScriptLoader/scripts/server/server.lua file that there should be a printout with "Script Loaded" which I do not get, which leads me to believe something's wrong with the installation of the script loader.

 

I should probably mention that I'm on the beta branch, if that matters.

 

 

 

Link to comment
Share on other sites

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
×
×
  • Create New...