20897 Posts in 3507 Topics - by 7110 Members - Latest Member: twodkyle

Author Topic: [Mod] Alpha! Carrier commands  (Read 29321 times)

Nexus

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
[Mod] Alpha! Carrier commands
« on: January 30, 2017, 06:41:07 AM »
DISCLAMER: When the 1.8 mod update is released, this mod install will be one way only. It will make non-reversable changes to your universe. A more detailed explanation will be added to the post as 1.8 nears

This mod adds a new UI to ships with hangars that will allow you to issue commands to launched fighters. While not perfect, it does aim to solve some of the issues with fighters and their limitations the best that it can. At least until koonchi gets a chance to work on them more.

The mod currently supports mining and salvaging fighters. The mod cant differentiate between the two, so it would be best if you limit your launched fighter type to one at a time. I am attempting to solve this, but its proving difficult. Most likely there is a API limitation preventing me from determining if a fighter is a miner or a salvager.

One thing I should note though, there can be intermittent problems with fighters not obeying commands. Also fighters wont go after loot directly like captained ships can, I tried and am still working on getting that part working. They will still pickup stuff if they get close enough though.

Installation:
Go to your Avorion installation directory, and drag the data folder into it. It will ask you to overwrite server.lua, do it the server.lua overwrite is needed to apply the new scripts I added.

The script should automatically apply to all ships with a hanger.

How to use:
The menu is only selectable from within the ship, so you must be currently piloting the carrier you wish to issue orders from. When you look in the upper right hand corner of the screen you should now see a second puzzle piece, that second puzzle piece will allow you access to the commands. Currently there are two commands, Salvage and Idle, hitting idle will disable the script. Maybe there will be more in the future =)

(1.7 Update) New command, Mine, fighters will seek out and mine ore rich asteroids only. An option will come later that will allow them to strip a sector.

Launch your fighters in defensive stance, it will only work if they are in this stance.

(1.5 Update) Now the commands will only be issued to fighters of the unarmed type, so miners and salvage. You can mix combat ships with salvage ships now.

Btw, if there is anyone who wants to suggest changes/optimizations to the code I'm all for it.

Uninstalling
Go to a close by empty sector before uninstalling, also your ship will most likely vanish after uninstalling..so break it down first

Due to the fact I'm binding a script to the player, if you uninstall this script you will need to do a few steps. First download the uninstaller script then install that like you would the mod, and leave the scriptloader.lua in its place. Then run the game once and load up the save, after it loads save and exit. You should now be able to remove scriptloader.lua safely.

If your installing this on a dedicated server, you should only have to run the uninstaller on the server itself.

Known Issues:
Putting fighters into 'attack my target' mode will cause them to stop working, that's an effect of the state, Keep them in defensive.
The salvage command effects all fighters not only salvage ones, working on it.(1.5 Update)Mostly fixed, commands only effect unarmed fighters now, so miners and salvagers.
The menu is available to ships without a hanger equipped.
Fighters wont go after drops directly, they will still pick up stuff they get close enough to, but that's it.

Changelog:
1.7(Current):
- Added mining Option, it currently only mines asteroids with resources.
- First iteration of a fighter settings menu.
- First set of *possible* fighter settings, at the time of this writing there are two settings being worked on.
    The first setting limits the number of fighters per wreck target -Has too many issues, need more time
    The second setting changes how wrecks are targeted, from the carrier position, to the fighter position. This disables the fighter limit per wreck as fighters will begin to spread out on there own anyways.
NOTICE: Only the menu UI for these options have been made, their programming hasn't been finished yet.
-Added tooltips for each option.
-Redid how the automatic unloader for scriptloader.lua. Instead of iterating through EVERY entity, it only gets those with the scripts attached.
-The salvage script for carriers auto terminates itself now when there is no wreckage left in the sector.

1.6:
Before installing 1.6, validate your files to remove the changes to defaultscripts.lua
-Removed changes to defaultscripts.lua(they are no longer needed)
-Script is now installed in the ship using onShipChanged rather than onSectorEntered, this means you no longer need to jump to another sector to enable the commands, they auto enable when you start/login to the map since each time you do that you 'enter your ship' so it always applies.
-Script now disables itself after the user logs off the server/world they are on. This is to assist with uninstalling
-Script now will clear itself from NPC ships..which where never meant to have it in the first place.
-Any galaxy created from 1.6 and up should not have any uninstall issues (ships vanishing/sectors being empty etc) so long as instructions are followed.
-Any galaxy created before 1.6 you will need to visit each sector you where in prior to uninstalling to remove the scripts from the NPC ships. If you don't your ship may randomly vanish when entering a sector, as a sector loading error will occur.
-You will notice a delay in logging off due to the script removal, this is normal.

1.5- MAJOR, Managed to get it so only non armed fighters will listen to salvage commands. So you can mix salvage fighters with combat fighters now. But don't mix salvage and mining fighters, as mining fighters count as unarmed.
1.4- Cleaned the script that handles attaching the new script to pre-existing ships. Faction issues should be completely solved with commanding fighters.
1.3- Scripts will now be properly applied to ships when jumping to another sector.
1.1- Cleaned up carriercraftorders.lua, fixed a derp with the code that was preventing the menu from showing up
1.0- Released
« Last Edit: March 15, 2017, 06:59:24 AM by Nexus »

Kane Hart

  • Sr. Member
  • ****
  • Posts: 271
  • The Talk Too Much Guy!
    • View Profile
    • My Youtube
Re: [Mod] Alpha! Carrier commands
« Reply #1 on: January 30, 2017, 07:56:36 AM »
Very Nice. I will have to give it a try soon :)

Tiberiumkyle

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #2 on: January 30, 2017, 08:09:21 AM »
Not working for me, dunno why.  Installed as you said to, launched game, no new orders, lack the extra puzzle piece you mentioned that should be in top right.  Double checked install locations, looked good there, restarted game, still nothing. Reinstalled the script, still nothing. Fighters just ignore wreckage unless I target it and tell them to attack.

Would your earlier captained ship salvage script be interfering? I do have that script installed, haven't tried yanking it out to try without, yet.

Nexus

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #3 on: January 30, 2017, 03:14:36 PM »
Not working for me, dunno why.  Installed as you said to, launched game, no new orders, lack the extra puzzle piece you mentioned that should be in top right.  Double checked install locations, looked good there, restarted game, still nothing. Reinstalled the script, still nothing. Fighters just ignore wreckage unless I target it and tell them to attack.

Would your earlier captained ship salvage script be interfering? I do have that script installed, haven't tried yanking it out to try without, yet.

There both independent, humm, ill have to check the files, i did do some trimming just before i put up the files. I may have broken something.

EDIT: HA oops, damn it...typed '!=' instead of '~=' in a single spot, this is probably a good reason why i should not post mods while half asleep =P
« Last Edit: January 30, 2017, 03:23:46 PM by Nexus »

Tiberiumkyle

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #4 on: January 30, 2017, 06:21:32 PM »
Removed the old scripts, installed the updated stuff... exact same lack of orders/new puzzle piece in top right. Have hopped out and back into ship, jumped sectors, restarted game, nothing, still.

Nexus

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #5 on: January 30, 2017, 06:34:57 PM »
Removed the old scripts, installed the updated stuff... exact same lack of orders/new puzzle piece in top right. Have hopped out and back into ship, jumped sectors, restarted game, nothing, still.

Humm strange, can you put up your log file by chance?

Also when you installed the mod, were you asked to replace defaultscripts.lua? i overwrite that file to add in the ship menu
« Last Edit: January 30, 2017, 06:44:04 PM by Nexus »

Tiberiumkyle

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #6 on: January 30, 2017, 06:48:32 PM »
Yes, replaced the defaultscripts.lua with your own. Lemme know if that's the wrong log, haven't yet poked at this games logging stuff.

Nexus

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #7 on: January 30, 2017, 06:54:02 PM »
Yes, replaced the defaultscripts.lua with your own. Lemme know if that's the wrong log, haven't yet poked at this games logging stuff.

All that matters is that its the most recent one =P

I see no errors in it....you know on a hunch is their a captain in the ship your in? This script only works on the ship your currently flying.

Tiberiumkyle

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #8 on: January 30, 2017, 06:55:46 PM »
There is. It's also the ship I'm usually flying myself, but still had no extra orders when I switched to drone and seleced it.

Nexus

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #9 on: January 30, 2017, 06:59:18 PM »
There is. It's also the ship I'm usually flying myself, but still had no extra orders when I switched to drone and seleced it.
ahh, thats the problem, you need to be inside the ship for the orders to show up. So get back in your carrier and check the upper right hand corner for a second puzzle piece.

Tiberiumkyle

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #10 on: January 30, 2017, 07:01:39 PM »
That's where I first checked, nothing. Nothing after getting back in, either.

Nexus

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #11 on: January 30, 2017, 07:05:14 PM »
That's where I first checked, nothing. Nothing after getting back in, either.
humm, ss by chance?

if all else fails try to run this command:
 /run local ship = Entity() ship:addScriptOnce("data/scripts/entity/carriercraftorders.lua")

You may still have to jump a sector and come back though

Tiberiumkyle

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #12 on: January 30, 2017, 07:15:18 PM »
Working only after entering /run local ship = Entity() ship:addScriptOnce("data/scripts/entity/carriercraftorders.lua"), jumped a sector before attempting to use, but the extra puzzle piece showed up immediately.

Nexus

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #13 on: January 30, 2017, 07:17:07 PM »
Working only after entering /run local ship = Entity() ship:addScriptOnce("data/scripts/entity/carriercraftorders.lua"), jumped a sector before attempting to use, but the extra puzzle piece showed up immediately.

Yes, i just managed to replicate the issue on my end as well..seems finicky ill look for a better solution to applying the script.

EDIT: oh..its not finicky.....it just defaultscript.lua seems to only be applied on ship founding...which is what i did, ill add something to the login code to check the playercraft for the script.
« Last Edit: January 30, 2017, 07:26:46 PM by Nexus »

Tiberiumkyle

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Re: [Mod] Alpha! Carrier commands
« Reply #14 on: January 31, 2017, 06:05:17 AM »
Working great in multiplayer so far, just two players though. While both of us have the scripts installed, I'm the only one to have used them so far, due to my friend not finding any salvage fighters in time to use em before calling it a night.