Author Topic: [MOD] Goods Hauler (Automatically buy/sell/move goods!)  (Read 45088 times)

Splutty

  • Sr. Member
  • ****
  • Posts: 258
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #15 on: March 31, 2017, 12:55:43 AM »
Loving your mod so far!

I'm curious towards the performance usage when a lot of players are using this at the same time, as the debug output is quite extensive.
I've also added it on the client so they can use the UI assuming there is not extra going on, but I could be mistaken ofcourse.

This spam is what concerned me:
Code: [Select]
Assert: Trading route reset, no viable trading route found in object
v0.9.2 Thu Mar 30 23:02:59 2017 (Lemming) data/scripts/entity/ai/haulgoods.lua: Empty list received, no queue left.
v0.9.2 Thu Mar 30 23:02:59 2017 (Lemming) data/scripts/entity/ai/haulgoods.lua: Found a dispatcher. (J_C 1)

Looking forward to your answer! :)

There's pretty much no impact from those messages.

I'm not sure if I already had the time delays in 0.9.2, but those checks happen at most once every 5 seconds. And when the ship can't find a useable trading route, it'll increase the wait time 5 seconds every time to a max of 60 seconds.

The only thing that costs any cycles at all is the initial building of the list, and even that's only minimal. I might put timings around some stuff to see how long it actually takes.

As for the client side, if you want people to be able to use the Orders -> Haul Goods command, you're going to have to do that yes. Otherwise it can be fully run on the server side, as long as you add the command to the right permissions group.

0.9.3 also has a change in debugging, where you can set some levels.

If you don't want debug messages at all, just change the debug_msg function.


tangowrangler

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #16 on: March 31, 2017, 10:26:01 PM »
Thanks for the mod. Was hoping for something like this to improve the station building aspect of the game. I can test it out cause I am playing in Rustys Galaxy and we recently got it there. I tried it out a little (for like 20 to 15 mins on  the server) and i have a suggestion: a command that forces trade with only player owned stations (or non-npc stations). I built liquor chain in a sector with tradepost that bought wheat. The little bugger was always selling it to the tradepost.

I found 2 issues:
1. The haulers tend to collide with ai ships already docked at stations. sad for rep.
2. One of the hauler had a cargo bay filled with lots of power cells that *I THINK* it wasnt selling. but that maybe due to the fact that it had bought it and there was a server restart in between. not sure.

Anywho, thanks for your work and your effort. It was great seeing the ship do its thing. It makes a great addition to the game. i am looking forward to playing with it more in an empty sector :)

Splutty

  • Sr. Member
  • ****
  • Posts: 258
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #17 on: April 01, 2017, 02:05:58 PM »
Thanks for the mod. Was hoping for something like this to improve the station building aspect of the game. I can test it out cause I am playing in Rustys Galaxy and we recently got it there. I tried it out a little (for like 20 to 15 mins on  the server) and i have a suggestion: a command that forces trade with only player owned stations (or non-npc stations). I built liquor chain in a sector with tradepost that bought wheat. The little bugger was always selling it to the tradepost.

Of course! That's where it can actually earn money  ;D

I also built in a check where it only transfers the largest amount possible. So if 1000 is needed somewhere, and a station sells 500 and another 100, it'll always pick the 500.

I'll have to think about how to implement a limitation on what stations it's allowed to visit.

I found 2 issues:
1. The haulers tend to collide with ai ships already docked at stations. sad for rep.
2. One of the hauler had a cargo bay filled with lots of power cells that *I THINK* it wasnt selling. but that maybe due to the fact that it had bought it and there was a server restart in between. not sure.

As to 1: There's not much I can do about that :( I've had NPC haulers squish my ships as well, and when I'm running 3 of them at once, they squish each other. The 'get a docking port' routine seems to always pick the same one, so everything piles up there.

I've been messing around a bit with the dock code, but I'm not sure if I can fix it in such a way that it doesn't affect a lot of other things. And I can't fix the 'playership getting crushed' issue at all.

For number 2, yes. If it's bought things and gets interrupted, then depending on who's the actual dispatcher and at what point it picks up again, it won't sell it. I've tried to alleviate this problem somewhat by making it so the hauler tries to sell everything if there's more in the cargo bay than what was originally planned, but that doesn't always work either.

For those things, there's still some manual intervention required, unfortunately.

Thanks for using it and posting the issues :)

tangowrangler

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #18 on: April 05, 2017, 09:42:04 AM »
Have been playing around more with your mod and have an idea regarding point 2.

Quote from: Splutty
For number 2, yes. If it's bought things and gets interrupted, then depending on who's the actual dispatcher and at what point it picks up again, it won't sell it. I've tried to alleviate this problem somewhat by making it so the hauler tries to sell everything if there's more in the cargo bay than what was originally planned, but that doesn't always work either.

Might an if check which looks for what the hauler has in its cargo and all the things it can sell in the sector before it starts doing trade routes alleviate the problem?

I must confess, i havent looked at your script yet. And after i am done doing these trade runs, i will have a look  8). if i have better ideas, i will let you know.

Splutty

  • Sr. Member
  • ****
  • Posts: 258
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #19 on: April 05, 2017, 01:07:02 PM »
Have been playing around more with your mod and have an idea regarding point 2.

Quote from: Splutty
For number 2, yes. If it's bought things and gets interrupted, then depending on who's the actual dispatcher and at what point it picks up again, it won't sell it. I've tried to alleviate this problem somewhat by making it so the hauler tries to sell everything if there's more in the cargo bay than what was originally planned, but that doesn't always work either.

Might an if check which looks for what the hauler has in its cargo and all the things it can sell in the sector before it starts doing trade routes alleviate the problem?

I must confess, i havent looked at your script yet. And after i am done doing these trade runs, i will have a look  8). if i have better ideas, i will let you know.

It might, but that's not really what the mod was for :)

I've thought about building in a 'recovery' mode, which saves and loads what it was doing last and tries to continue doing that, but haven't gotten around to that yet.

I mainly built all this for my own sector with my own factories, so it's not really very multi purpose. It will work in a sector where you can do trade between NPC stations as well, since that was only a small adjustment to make.

A bigger problem is ships getting stuck on each other when they're at the same docking port. Since getting a 'random' docking port doesn't seem to be random at all :)

tangowrangler

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #20 on: April 05, 2017, 02:28:47 PM »
Had a skim of the script. The relative complexity and my lack of knowledge of lua led to very shallow understanding. Thankfully, i found the /haulgoods status command while re-reading your title post.

I mainly built all this for my own sector with my own factories


It might, but that's not really what the mod was for :)

I mainly built all this for my own sector with my own factories, so it's not really very multi purpose. It will work in a sector where you can do trade between NPC stations as well, since that was only a small adjustment to make.

This is what I am hoping to use it for. the problem is I built my things in a neutral zone where there are trade posts. So it sometimes makes those trades. Thats why I was thinking maybe when u populate your table in your "buildGoodsList" function, there can be column which stores the owner of the station. Later that information maybe used to restrict the hauler to only the players station.

I've thought about building in a 'recovery' mode, which saves and loads what it was doing last and tries to continue doing that, but haven't gotten around to that yet.

Regarding the recovery mode, it can be useful even when building in an empty sector because of servers crashes. I do not know what is easier, checking the cargo, or periodically writing the state. I am gonna see if there is any way to give captain commands to the ship i am commanding. Sth I would really like to be able to do. Also gonna play around with the haulgoods status command.

P.S  I myself imagine/assume many things are possible (modwise), but my lack of programming experience makes me overzealous. so excuse me if i sound thick.  :)

Cheerio

Spacefaring_Guy

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #21 on: April 10, 2017, 06:35:16 PM »
I do not know what is easier, checking the cargo, or periodically writing the state.

I know I certainly don't know the answer to that for scripting, but if we look at it in terms of how it might work in the real world... you know what cargo you have, but you may have forgotten your route.  So since you KNOW what cargo you have, and your job is to sell whatever you can... start from scratch.  It's a long chain query, though, because there's probably a nasty, nasty web of possibilities to choose from.

I'd do something like:

List of all stations that will buy my cargo

tangowrangler

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #22 on: April 10, 2017, 10:04:48 PM »
From the metadata of your quote i thought u were talking to Splutty. hehe

List of all stations that will buy my cargo

Anywho, the code already makes a list of the goods being bought and sold in the sector. It is done using the buildGoodsList function in the haulgoods.lua file. incase you feel inspired to have a look at the script and change it for the rest of us ;)

Spacefaring_Guy

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #23 on: April 11, 2017, 03:48:08 PM »

Anywho, the code already makes a list of the goods being bought and sold in the sector. It is done using the buildGoodsList function in the haulgoods.lua file. incase you feel inspired to have a look at the script and change it for the rest of us ;)

I have no idea what happened, but that post stopped about 1/4 of the way through what I recall having typed up... and now I can't remember any of it.  It probably seemed brilliant at the time, too.  Developers around the world will mourn the loss of my genius. :)

In future, I will attempt to post less frequently while running on caffeine instead of sleep.

Devious

  • Hero Member
  • *****
  • Posts: 579
  • Have you seen Rusty?
    • View Profile
    • Rusty's Universe and Community
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #24 on: April 11, 2017, 05:37:02 PM »
After testing it a while on our server it seems there is an increase in server load when multiple ships are hauling goods in multiple sectors. It came to mind after jumping around trying to narrow down the cause but all I could find were 3 afk players hauling goods in their sectors that could have a significant load.
It might have more to do with how the game handles updates as one laggy sector slows down everything else and the cause might also lie somewhere else as we use many more mods tho.

Would it be possible to somehow limit the amount of ships a player can use to haul goods?
The few players I found were using 3-6 ships so that might have something to do with it.

Splutty

  • Sr. Member
  • ****
  • Posts: 258
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #25 on: April 13, 2017, 05:16:58 PM »
After testing it a while on our server it seems there is an increase in server load when multiple ships are hauling goods in multiple sectors. It came to mind after jumping around trying to narrow down the cause but all I could find were 3 afk players hauling goods in their sectors that could have a significant load.
It might have more to do with how the game handles updates as one laggy sector slows down everything else and the cause might also lie somewhere else as we use many more mods tho.

Would it be possible to somehow limit the amount of ships a player can use to haul goods?
The few players I found were using 3-6 ships so that might have something to do with it.

It must be some other mod interfering with mine, since there's no way my mod uses up any sort of significant CPU even with 100 haulers. (And yes, I've tried that :)

So not sure what's affecting it. But each sector only has 1 ship building the actual list, and if it fails that it'll try to rebuild it in increments of 5 seconds, and the rest basically does nothing and will also increase their polling interval by 5 seconds up to 60 seconds.

So the most impact you can possibly have is one goods rebuild every 5 seconds if there's nothing to haul (and with my system with 50 stations that takes a very short time), and one inter-object call for each of the haulers doing nothing every 60 seconds.

If they actually *are* doing something, they do a check every 5 seconds if the previous step has finished, and kick off a new flying or docking step. That's about it. I can't see how any of that has any impact.

I'll build some timings in my next version, though. Always interesting to see what might be causing this sort of stuff :)

Stavinsky

  • Newbie
  • *
  • Posts: 15
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #26 on: April 29, 2017, 05:41:14 PM »

Hello,

your mod is a great idea and really hope it will be added in the game in a way.

Right now I have a bit of a problem, when entering a sector that was set as a regenerative
I end up having a couple of issues with the ship commands in Keyboard-mouse playing.

Like for example the inability to toggle on-off the turrets groups

or suddenly having the 'invert speed' getting all crazy and unable to be stopped

Tridi

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #27 on: May 10, 2017, 01:36:15 AM »
I love your mod.  It doesnt seem to work with Complex3s mod though.  Is there a way to make it work.

Splutty

  • Sr. Member
  • ****
  • Posts: 258
    • View Profile
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #28 on: May 27, 2017, 06:57:37 PM »
I love your mod.  It doesnt seem to work with Complex3s mod though.  Is there a way to make it work.

If you use the / commands to control your ships, the mod shouldn't interfere with any other mods at all, since it doesn't modify any source files.

Not sure which mod you mean that gives problems, though :)

Devious

  • Hero Member
  • *****
  • Posts: 579
  • Have you seen Rusty?
    • View Profile
    • Rusty's Universe and Community
Re: [MOD] Goods Hauler (Automatically buy/sell/move goods!)
« Reply #29 on: May 27, 2017, 07:00:28 PM »
I think he means that it doesn't work with a factory complex, which is a mod that merges stations together into one (made by Laserzwei). That's probably why it isn't working, as it's no longer a normal station.