Skip to content

Instantly share code, notes, and snippets.

@myxal
Created March 4, 2020 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save myxal/afd1c1d8754af2fc927a087578b587e7 to your computer and use it in GitHub Desktop.
Save myxal/afd1c1d8754af2fc927a087578b587e7 to your computer and use it in GitHub Desktop.
Worldmigrators, shard linking, in Don't Starve Together
# Here you'll find various code snippets for dealing with world migrators.
# Original source, and more info: https://forums.kleientertainment.com/forums/topic/59174-understanding-shards-and-migration-portals/
1) Join a server
(We are in master now, shard_id is 1)
2) c_spawn("cave_entrance")
(Cave entrance will be id 11, automatically, since there were 10 cave entrances by default on generation)
3) Stand near the entrance, as c_find picks the closest thing
4) c_find("cave_entrance_open").components.worldmigrator:SetDestinationWorld(shard_id,true)
(This shard id will be the second slave)
5) Use the entrance
6) You will migrate to slave 2, from portal 11 from master
7) Since only 10 cave exits are here, you will go somewhere else, find a place to make a new exit
8) c_spawn("cave_exit")
(This cave exit will be id 11, automatically, since there were 10 cave exits by default on generation)
9) c_find("cave_exit").components.worldmigrator:SetReceivedPortal(shard_id, 11)
Caves: 2
Third: 3
Travelling:
c_gonext("cave_entrance")
c_gonext("cave_entrance_open")
c_gonext("cave_exit")
c_gonext("migration_portal")
Modification:
mig=c_find("cave_entrance_open").components.worldmigrator
mig=c_find("cave_exit").components.worldmigrator
mig=c_find("migration_portal").components.worldmigrator
mig:SetDestinationWorld(shard_id,true)
mig:SetDestinationWorld("1",true)
mig:SetReceivedPortal(shard_id,migrator_id)
Debugging:
print(mig:GetDebugString())
print(c_find("cave_entrance_open").components.worldmigrator:GetDebugString())
print(c_find("cave_exit").components.worldmigrator:GetDebugString())
print(c_find("migration_portal").components.worldmigrator:GetDebugString())
for k, v in pairs(Ents) do if v.prefab == "cave_exit" then v.components.worldmigrator:SetDestinationWorld("1",true) end end
for k, v in pairs(Ents) do if v.components.worldmigrator ~=nil then print(v.components.worldmigrator:GetDebugString()) end end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment