Tabletop Simulator

Tabletop Simulator

View Stats:
Splizard Nov 5, 2014 @ 5:23pm
What is the structure of a .cjc file?
Devs, could you please release a specification so that modders can play around with the files? :)
< >
Showing 1-14 of 14 comments
Knil  [developer] Nov 5, 2014 @ 11:19pm 
I'll be expanding on this more on Wiki when I flesh out the documentation, but basically the .cjc file is just a serialized list. With entry 0 containing containing generic game state information and everything after that is an object on the table.

The values contained in each object on the list is this:

public string name;
public int idint;
public float posX;
public float posY;
public float posZ;
public float rotX;
public float rotY;
public float rotZ;
public int MatInt;
public int MeshInt;
public int LayerInt;
public int Num;
public bool bAltSound;
public List<int> List;
public Mode ModeState;
public string Note;
public string PlayerTurn;
public List<string> StringList;
public List<string> CustomList;

Overall it wasn't the best system, but it works haha. If I could do it over again I would have done it with xml to make it easier for modders. I'll go into more depth when I get around to it.
Last edited by Knil; Nov 5, 2014 @ 11:20pm
Splizard Nov 6, 2014 @ 1:36pm 
alright thanks for the reply! are you using a BinaryFormatter?
It does seems a bit hard to maniplate, I'm guessing it's a specific CSharp serialisation implementation.. ?
XML would be nice xD

My idea for being able to edit the files was that a mod/tool could create a workshop file with mod-generated objects that players could import those objects individually from the file with the new workshop specific object importer.
Like how my decker tool that creates TCG decks could then pop the user-generated decks into the same workshop file and players can simply pull out all their custom made decks from that workshop file (.cjc).
The only issue I see with this approach is that the deck image would only be on the host so a way of downloading images from the host would be nice.
Knil  [developer] Nov 6, 2014 @ 3:57pm 
Scroll down to CJCurrie's response.
http://answers.unity3d.com/questions/8480/how-to-scrip-a-saveload-game-option.html

The formatting seems to be a bit messed up on the Unity Answer atm, but it's how I am doing the serialization. I'm not sure how easily reproducible it will be.
Last edited by Knil; Nov 6, 2014 @ 3:58pm
Splizard Nov 7, 2014 @ 1:45pm 
Thanks, sadly I don't have much experience with c#, compiling that code and running
the Load function on a save file resulted in:
System.TypeLoadException: Could not load type 'System.Collections.Generic.List`1[[PhysicsState, Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]'.
I guess that is the game state information?
I'm unsure how to load it into a dummy type or the like.

Would you be able to provide an open-source simpe CSharp cjs Load/Save implemetation which simply loads the file into the respectve types and can save them again after modification?
I think I'd be able to find may way after I have a working decoder/encoder.

No hurry though, if you are considering moving to a different format like xml I'll wait until then.
Scootaloo Nov 9, 2014 @ 11:08am 
If I may toss out an idea, there's no reason not to use an XML file, even if you're already doing the serialized list.

When the file loads, just check to see if it's the old file format or the new xml based one, or even change the file extension on the new version. All the old files still work, and anything that gets saved or resaved end up with the new file format.

An XML based save would be a huge benefit to modders. If you have 10 doohickeys with a different texture for each, you currently have to copy/paste 20 URLs from outside the game (16 if you plan ahead an re-use the copy buffer for the model for every second import). With an XML file, you just select the object group, copy-paste-paste-paste-paste and then change the texture URL. Actually, more likely you'd spawn 10 in-game, save, then edit the URLs so you don't have to fiddle with the XYZ positioning manually.

I had to write documentation on a file format once. It ended up being faster to rewrite the file format to have less nuances than to try to explain all of them.
Knil  [developer] Nov 9, 2014 @ 11:23am 
Ya that was my idea too, the problem is the working on redoing saves hasn't been a priority due to it already working. Triage.

But I would love to see it done so maybe soon :)
Last edited by Knil; Nov 9, 2014 @ 11:29am
Scootaloo Nov 9, 2014 @ 11:31am 
A fair point. I assume we'll be seeing XML save files the next time you have to change the safe file structure anyway ;) .

Everyone else: Try to make suggestions would need to be preserved in a save file.
Knil  [developer] Nov 9, 2014 @ 11:39am 
Json might even be better for readability, we shall see.
Last edited by Knil; Nov 9, 2014 @ 11:51am
Scootaloo Nov 9, 2014 @ 12:02pm 
Either or. If I ever say XML, assume it's a euphemism for "Readable thing". Frankly I find XML to be annoyingly verbose, but it's more likely that people will get what I'm talking about. Like saying "Band-Aid" instead of "Adhesive Medical Strip".
Knil  [developer] Nov 10, 2014 @ 4:30pm 
Been messing around with serializing as Json and I'm liking it so far.

http://pastebin.com/kJ1dFV6h

Just a sample not everything is working properly, but a ton more readable.
Splizard Nov 11, 2014 @ 12:07am 
Sweet :) +1
Knil  [developer] Nov 26, 2014 @ 11:48am 
New Json format is in action let me know if there are any questions.

There's a page on the Wiki I'm currently working on for some more info.

http://www.berserk-games.com/wiki/tabletop-simulator/save-file-format/
Splizard Nov 26, 2014 @ 2:11pm 
Awesome! is there any plans to add peer to peer image sending so images don't need to be hosted online? I'll be incorperating a system to my deck generator to place the decks straight in the chest, with local images.
Knil  [developer] Nov 26, 2014 @ 3:56pm 
Maybe, the problem is that saves no longer function on their own when they require the host to have the files locally. (Can't just send them the .json file)

Also eating up the hosts bandwidth to sync massives mods will be very slow especially if there are more than 4 people.
< >
Showing 1-14 of 14 comments
Per page: 1530 50

Date Posted: Nov 5, 2014 @ 5:23pm
Posts: 14