Difference between revisions of "Creating New Levels"
(Initial findings on creating unique lobbies) |
(No difference)
|
Latest revision as of 04:06, 19 June 2021
Creating Levels with unique Lobbies
To create a truly new level, you need to make it have a unique ID number (Uid), so that it will have its own unique lobbies instead of sharing lobbies with another level. Level Uids and names are stored in the levelUids and levelNames tables, which are initialized in LevelUid.lua.
Setting up the level
It seems like you can't just add extra levels with a new name/Uid to the tables, or your game will crash when you try to load that level - to avoid crashing, you probably would need to embed resource .lua's into Journey.exe with the new level's name, and maybe need to make other changes as well.
Here is a workaround method that should work fine for making a "new" level with its own lobbies, and you don't need to try to cram extra lua's into the .exe:
1. Before the player enters a level, change that level's Uid, for example:
--changes Level_Bryan in the levelUids table from the default "level 9" to "level 9001"--
levelUids["Level_Bryan"] = 9001
--might be unnecessary, but maybe should do this just to be safe: removes "9" from the levelNames table and adds "9001" defined as Level_Bryan--
levelNames = {}
for name, uid in pairs( levelUids ) do levelNames[ uid ] = name end
--not part of the Uid-changing code, this just makes the player enter Level_Bryan, which is now being treated as "level 9001"--
game:QueueLevel("Level_Bryan")
2. As the level loads, make changes to the resources being loaded so that the level is customized however you want. It's still unknown how to "correctly" load resources like the game does for the normal levels, see Loading Level Resources With Lua for partly-working methods found so far.
3. Any players who use your mod will be in a level with the same name and Uid, so they will be put in the same lobbies and can connect normally if they meet the usual distance/flag-related connection requirements. So far there are no known differences from how lobbies/connections work in normal levels.
4. You shouldn't change the level's Uid again until the level is over - the game frequently checks the Uid, and if it changes then you will soon disconnect from a companion with a different Uid and/or you will be moved from your current lobby into a lobby that matches the new Uid.
5. If you construct your modded level based off anything other than CS, Paradise, Level 09, or a credits level, and there's any chance that the player can play through that level normally while using your mod, make sure that something will reset the level's Uid to its default number in both LevelUid tables by the time the player enters the unmodded level - because if it still has the modded Uid, they won't be able to connect to anybody.
Why unique lobbies are important
If you publish a modded level that has noticeable gameplay-related differences and not just cosmetic differences, you really should make it use its own lobbies, because using the same lobbies as another level can make the game less enjoyable for everyone:
- If you just change some level resources, players may meet companions in "the same level" but it has different terrain, physical geometry, Trigger events, etc - which would be confusing for players who don't mod, and even if both players know what is going on it might be difficult or impossible to play together. Some things might even cause crashes somehow.
- It seems like if you change all level resources, or maybe just certain type/s, players in "different levels" will not be able to meet each other but will still share the same lobbies, making it harder for everyone to find a companion.
- For example, if a lobby filled up with the usual maximum 16 players, but they're evenly split up between 4 "different" levels, every player has only 3 other players they could meet in the entire level; any more compatible players joining the level would go into a different lobby and be unmeetable. This may be only a minor issue right now, since there aren't many published level mods yet, but it is worth planning ahead to keep it from ever being a problem in the future.
Modded Level Uid list
If you publish any modded levels using unique Uids, please record them in the Modded Level Uid List.
LevelUid.lua's code comments say that the Uid is a "unique 8-bit identifier", which would mean only 256 Uid's are available, but it seems like the largest Uid number that doesn't crash the game is actually somewhere between 6.5 to 7 million. So, we'll probably never run out of available Uids, but it's still a good idea to keep track of the ones that are already in use, so other modders can be sure they don't accidentally use the same ones and get lobbies mixed up.
Other Details
- You can exit a level and enter a new level with the same name/base resources, and it should work the same as entering a level with a new name - for example, at the end of Level_Bryan/level 9001, you can change Level_Bryan into level 9002, load Level_Bryan, modify it to load a completely new set of level resources, and even though you are still in a modified "Level_Bryan" it is a different level in probably every way .
- If two players are in a level with the same Uid but a different Level Name, they almost certainly won't be able to connect - not actually tested yet, though. However they will both go into the same lobbies even if they can't meet.
- If you use a negative number for a level's Uid, the game will crash when it tries to load that level.
- As stated above, a Uid can be set up to at least 6500000, but somewhere between that and 7000000 the number is too high and the game will crash if you load that level.
- Default levelUid table values:
{ ["Level_Graveyard"] = 0
, ["Level_Barrens"] = 1
, ["Level_Desert"] = 2
, ["Level_Canyon"] = 3
, ["Level_Cave"] = 4
, ["Level_Ruins"] = 5
, ["Level_Mountain"] = 6
, ["Level_Summit"] = 7
, ["Level_Credits"] = 8
, ["Level_Bryan"] = 9
, ["Level_Matt"] = 10
, ["Level_Chris"] = 11
}