Jump to content

REQ: Mod to respawn resources (In starting sectors)


Devious

Recommended Posts

I like the idea for everyone to start in the same sector, but with the meteorites being non-renewable this can turn out pretty ugly.

 

I have already a few players who need to spend a lot of time and jumps before finding iron, if it would be possible to respawn the nodes there would be no need to set the server up so that everyone spawns in their own sector.

 

Not sure if it's possible to do it automatically for the starting sector but being able to input sector coordinates to respawn could work.

Link to comment
Share on other sites

Hey there! I made something that I think fits what you're looking for.

 

This script, when attached to a Sector, causes any destroyed asteroids with resources to respawn as a new random asteroid with resources befitting the Sector sometime within mintime and maxtime, as defined in the script.

 

I attached it to every sector by adding

Sector():addScript("data/scripts/sector/resourcerespawn.lua")

after the

Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")

in all of the sector generation functions.

 

If you wanted it to only run in the start sector, I'm not certain where the best place would be to add it in the scripts, but you could run it manually via the chat at that point by just manually executing

/run Sector():addScript("data/scripts/sector/resourcerespawn.lua")

 

The one drawback here is that the script won't spawn new resources (I tried that first, determining fitting positions was a nightmare, not to mention I wouldn't really know if things intersected), so you have to get it running on the sector before anyone mines it. All your players will need the script also I believe, I'm not really sure, this has been a learning experience.

 

EDIT: I forgot to mention, place the script in data/scripts/sector as seen in the function calls.

EDIT 2: Fixed a problem with script.

 

I actually made this script the same day you made this post, but the forum wouldn't allow me to complete registration on my primary email, so I finally ended up doing another registration with a gmail.

resourcerespawn.lua

Link to comment
Share on other sites

thanks for the mod running it from chat works ok but in which .LUA file and where in the file do i place the Sector():addScript("data/scripts/sector/resourcerespawn.lua") command so i can get resources spawning in all sectors. or can i just toss it in any where in the .LUA file as long as its in the file?

Link to comment
Share on other sites

There are sector generation scripts in the scripts/sectors directory. If you want resources to respawn in every sector, you can find the line where the events script is added in each of those sector generation script files and paste the line to add my script to the sector there.

Link to comment
Share on other sites

Certainly!

 

Here's an example, this is where I placed the function to add the script in one of the sector generator scripts, asteroidfield.lua:

 

ncNKpdj.png

 

When I did this I actually just did a blanket search/replace for the entire directory using Notepad++, but the easy objective is to look for that other line where the events script is added and stick the line to add my script right after.

Link to comment
Share on other sites

Hi,

 

People on my server have been asking for this as well. However, I'd only want to spawn the resources in the starting sector, not everywhere in the universe.

 

I'm no coding wizard but what would happen if I'd fill out the sector location inside the parameters?

 

E.g.  Sector(415:-8) :addScript("data"/scripts/sector/resourcerespawn.lua")

 

Not sure if that works, but otherwise I don't see why there's parameters to begin with.

 

Anyone who's tried this / got that working at all?

 

Thanks!

Link to comment
Share on other sites

Heya Linkfish. If you load into the game and do it through chat, the script will persist indefinitely. So if you only have one starting sector then it's just a one-time set and forget for the server.

 

As far as noted in the scripting docs, the Sector() constructor does not accept any arguments, so it can only return the sector that the current script is running in I believe.

 

EDIT: I guess I should mention, now that I think about it, there is an obvious solution here. The startsector.lua script gets run on player faction owned sectors only, so whether you only have one of them or multiple, adding the call in only that script will cause resources to respawn in all start sectors.

Link to comment
Share on other sites

Hi there,

 

i added the line

Sector():addScript("data/scripts/sector/resourcerespawn.lua")

after this line

Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")

 

Is the mod running automatically in the background? Or is something missing?

 

Tested it in a existing "hosted Multiplayer Game", but no ressources spawns :(

 

dont nothing know about modding/scripting :(

 

 

Link to comment
Share on other sites

  • 4 weeks later...

hi, thx for that script.

 

i added the line;

Sector():addScript("data/scripts/sector/resourcerespawn.lua")

below the line

Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")

 

in every file which have that last line;

 

~#data/scripts/sectors#grep -r -i 'pirateattack.lua' ./
./piratestation.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./piratefight.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./lonewormhole.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./colony.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./lonetrader.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./containerfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./asteroidfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./asteroidfieldminer.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./miningfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./lonescrapyard.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./cultists.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./loneconsumer.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./factoryfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./smallasteroidfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./wreckageasteroidfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./pirateasteroidfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./stationwreckage.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./loneshipyard.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./gates.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./functionalwreckage.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./lonetradingpost.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./wreckagefield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")

~#data/scripts/sectors#grep -r -i 'resourcerespawn.lua' ./
./piratestation.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./piratefight.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./lonewormhole.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./colony.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./lonetrader.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./containerfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./asteroidfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./asteroidfieldminer.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./miningfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./lonescrapyard.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./factoryfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./smallasteroidfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./wreckageasteroidfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./pirateasteroidfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./stationwreckage.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./loneshipyard.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./gates.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./functionalwreckage.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./lonetradingpost.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./wreckagefield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")

 

i lowered the respawn time on server to min 10.0 and max 20.0 to test that script.

does a server restart and a start with a new galaxy.

but it doesn't work. then i copied the file to my client; no result, too.

 

i'm running a dedicated public server with ubuntu server.

 

DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"
NAME="Ubuntu"
VERSION="16.04.2 LTS (Xenial Xerus)"

 

 

 

Link to comment
Share on other sites

hi, thx for that script.

 

i added the line;

Sector():addScript("data/scripts/sector/resourcerespawn.lua")

below the line

Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")

 

in every file which have that last line;

 

~#data/scripts/sectors#grep -r -i 'pirateattack.lua' ./
./piratestation.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./piratefight.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./lonewormhole.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./colony.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./lonetrader.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./containerfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./asteroidfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./asteroidfieldminer.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./miningfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./lonescrapyard.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./cultists.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./loneconsumer.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./factoryfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./smallasteroidfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./wreckageasteroidfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./pirateasteroidfield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./stationwreckage.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./loneshipyard.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./gates.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./functionalwreckage.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./lonetradingpost.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")
./wreckagefield.lua:    Sector():addScript("data/scripts/sector/events.lua", "events/pirateattack.lua")

~#data/scripts/sectors#grep -r -i 'resourcerespawn.lua' ./
./piratestation.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./piratefight.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./lonewormhole.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./colony.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./lonetrader.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./containerfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./asteroidfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./asteroidfieldminer.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./miningfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./lonescrapyard.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./factoryfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./smallasteroidfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./wreckageasteroidfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./pirateasteroidfield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./stationwreckage.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./loneshipyard.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./gates.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./functionalwreckage.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./lonetradingpost.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")
./wreckagefield.lua:    Sector():addScript("data/scripts/sector/resourcerespawn.lua")

 

i lowered the respawn time on server to min 10.0 and max 20.0 to test that script.

does a server restart and a start with a new galaxy.

but it doesn't work. then i copied the file to my client; no result, too.

 

i'm running a dedicated public server with ubuntu server.

 

DISTRIB_DESCRIPTION="Ubuntu 16.04.2 LTS"
NAME="Ubuntu"
VERSION="16.04.2 LTS (Xenial Xerus)"

 

I'm having the same issue as you. I am looking to hook the sector entered event then use that to add the script. I don't know if it's the correct way, or if it will work...

Link to comment
Share on other sites

  • 9 months later...

I placed the file in the correct location.  I run the command and it errors that if can not locate the file.

I change the / to \ and run it again and it then errors that it cant find data(-28.11)criptsesourcerespawn.lua

yes its missing the s and r

 

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...