Jump to content

Forcing Island Retrofit

Recommended Posts

I've ran multiple island retrofits on my solo world. Each time the island seems to generate at the same coordinates (not sure if exactly, but visually it seems to be the same area) but the orientation changes. The island can flip or rotate (aligns to grid, seems to be 90 degrees probably) but that's the seeming extent to the variability/chance/rng of the process.

I'd really like to be able to force the island to generate in a more favourable area as this is a long established world and it's a far ways away from what I've built. Is it possible through some means to force the island to generate at certain coordinates that I could choose? Maybe through a long ass console command string or perhaps a mod or batch file or something?

Curious to pick ur brains if that's possible and if so, if it's currently available to me to use?

I haven't been able to move on with my solo world since the island retrofit was introduced to main branch, and I'd really like to now. Thanks for any help you guys can provide.

Link to comment
Share on other sites

you can see the code for island retrofit in scripts/map/ocean_retrofit_island.lua
The problem now is to change this code... it is neither a class nor component, so we can not use these commands.
You could try to copy paste the file into a mod in scripts/map folder and add some print statements to the file to see if it gets executed instead of the original one.

If that also does not work and since it is only for one-time retroffiting, you can also make a backup of the scripts.zip, then modify the original file to your liking and zip the scripts folder again. Then the game will use the zipped scripts folder with your modified file. After the retrofit worked, you can use the original zip again.

Edited by Serpens
Link to comment
Share on other sites


Ty so much for your reply to my question in Mods & Tools about forcing the island retrofit to insert the island where I'd like it. I've found ocean_retrofit_island.lua. How do I make it a mod and can u provide an example of a print command so I can try the 1st step to making this happen? 

hm.. if you not even know how to add print statements, you also wont know how to adjust the code to spawn the island somewhere else, right?
To figure this out might take some hours and one would need your savegame (to get the cooridnates you want the island to spawn).
I have no time currently to do this everything for you, sorry.

But everyone with just a very little coding experience can help you with that.

Link to comment
Share on other sites


I already determined the coordinates should be in the area of -700,700 (X,Z).

I know a print function looks something like the following:

-- Simple print just to show if a function was called.
print("MyFunction was called")

However I've never made a mod before so I don't know how to set it up to look like one. Need a modinfo.lua and a modmain.lua? Or just do the temporary .lua replacement. I fundamentally just want to direct it to put the island in that coordinate range. I'm hoping if I just force the retrofit a bunch of times I'll eventually get an orientation that works (I know what I'm looking for) and the default script is giving me the largest retrofit island so hopefully that would stay the same.

Please write your response in this thread, not via private message. Others might have the same question.

I wrote you in my first response what to do.
I attached a sample mod testmod.zip. Unpack the zip and put the testmod into your DST modfolder, so it looks eg like this
Steam\steamapps\common\Don't Starve Together\mods\testmod
I already included the ocean retrofit lua from DST. You can open that file and modify it, eg adding the print at the beginning of the file.
Then activate the mod and start the game (create a new world without caves, just for testing). After that you go to Documents\Klei\DoNotStarveTogether and open the client_log.txt. search if you see your print there (so in your example, search for "MyFunction was called" without quotes.)
If you find it, great, then you can simply modify the file to change the location of the island.

If you dont find it, it wont work that way (some files work like this, other dont, I dont know which do work, that is why you test it)
If it does not work, you have to change the gamefiles directly without a mod.
To do so you unpack the scripts.zip from DST, change the ocean retrofit file to your linking and then pack the scripts folder again to zip. This new zip replaces the orginal scripts.zip (make a backup from the original somewhere else, or check files with steam after you succeeded). Start the game and now it should load your new ocean retrofit file. Check again if your print is now printed, it should work now. Change the coordinates in the file and try to make the island spawn at your location.


Edited by Serpens
Link to comment
Share on other sites

Does it matter where you put the print command line? I tested the mod with it as the very first line in the .lua, immediately after the first 3 lines, and underneath the very last, leftmost 'end' on its own line, with a single space above or below it if applicable. I generated a new world without caves. None of those tests resulted in me finding the print message in the client_log.txt.

I then did the same thing to the .lua in the scripts.zip, saved, and ran the game/created a new world. I couldn't find the print message in the client_log.txt either. What's going wrong?

Does it work to test it without using a world that requires retrofitting?

Link to comment
Share on other sites

oh, yes, seems the file is only loaded when retroffiting, so try again with your old world (you can force quit the game to prevent saving, but I guess you know that :D).
You can also modify another file, eg. in prefabs the player_common.lua and add a print at the beginning. This way you can make sure that your modification was succesfull.

in ocean retrofit file you put one print at the top and one print inside the "TurnOfTidesRetrofitting_MoonIsland" function, so directly after the line "local function TurnOfTidesRetrofitting_MoonIsland(map, savedata)".
As soon both prints are in logfile, you can start modifying this TurnOfTidesRetrofitting_MoonIsland function.

This function tries to call 3 times the "TryToAddLayout" function, like you see at the bottom of it "local success = ...".
So it tries to place the big island first and if this does not work then smaller ones.

I think the "Another way" below is better and saves time.
((Within this try-function first you could try to print the "candidates". So after the line "if #candidtates > 0 then" you could write: dumptable(candidtates) to print the content of this list. Then you will see how many possible positions where found. Find out if the position you would prefer is already within the candidtates. If so, you only have to remove all the other ones and you are fine.))

Another way, if this does not work, would be to write your own candidtate, so before line "if #candidtates > 0 then" you simply define:
candidtates = { {top = top, left = left, distsq = VecUtil_LengthSq(left - map_width / 2, top - map_height / 2)} }
and put your custom values in for top, left. I think distsq can be any number (make it 0), since it is only used if more than one candidtate is given, to find the best.

Edited by Serpens
Link to comment
Share on other sites

With someone's help I was able to modify ocean_retrofit_island.lua and force the island size used and the x,y position on the map, but it's proving difficult to get the island orientation i'm looking for (orientation/flip). Can you see a way to force which flip direction and orientation of the island is used during the retrofit?

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