Welcome to the new Diaspora forums, please let us know if you see anything broken! Notice: Some users may need to reupload their avatars due to an issue during forum setup!
Ship saver and loaders
These nifty chips I just made should help when building ship hulls. The saver saves all the props in a ship every minute when you paste it on your ship. Just set a file name in the code and it will auto-save. Keep in mind entities can not be saved since ent core is not enabled on the server.
Now, that saves your ship, but you're going to need something for loading your ship. This chip will load the file you put in. It will repaste everything back where you were building it originally, with all colors, alphas, materials, skins, and angles the same as before. The constraints will re-weld every prop to the first one spawned, so you will have to re-do any special welds. It's better than losing it all though!
@name Ship Saver @persist Contraption:table @persist [Con, Pos, Color, Mat, Mod, Ang, Skin]:array @persist File:string I if (first()) { #By Katelyn ##### EDIT ONLY THIS ##### Name = "testship" # This variable is the name of your save file. You use it to recall it. ##### EDIT ONLY THIS ##### File = "Advduper/" + Name + ".txt" timer("save", 100) } if (clk("save")) { Con = entity():getConstraints() timer("vars", 100) print("Saving...") I = 1 } if (clk("vars")) { if (I <= Con:count()) { Pos[I, vector] = Con[I, entity]:pos() Color[I, vector4] = Con[I, entity]:getColor4() Mat[I, string] = Con[I, entity]:getMaterial() Mod[I, string] = Con[I, entity]:model() Ang[I, angle] = Con[I, entity]:angles() Skin[I, number] = Con[I, entity]:getSkin() I++ timer("vars", 25) } else { Contraption["pos", array] = Pos Contraption["color", array] = Color Contraption["mat", array] = Mat Contraption["mod", array] = Mod Contraption["ang", array] = Ang Contraption["skin", array] = Skin fileWrite(File, glonEncode(Contraption)) timer("save", 60000) print("Saved " + Con:count() + " props.") } }
Now, that saves your ship, but you're going to need something for loading your ship. This chip will load the file you put in. It will repaste everything back where you were building it originally, with all colors, alphas, materials, skins, and angles the same as before. The constraints will re-weld every prop to the first one spawned, so you will have to re-do any special welds. It's better than losing it all though!
@name Ship Loader @persist Contraption:table @persist [Con, Pos, Color, Mat, Mod, Ang, Skin]:array @persist File:string I if (first()) { #By Katelyn Name = "testship" #for loading reasons. File = "Advduper/" + Name + ".txt" if (fileCanLoad()) { fileLoad(File) } runOnFile(1) } if (fileClk()) { if (fileStatus() == _FILE_OK) { Contraption = glonDecodeTable(fileRead()) timer("vars", 100) Pos = Contraption["pos", array] Color = Contraption["color", array] Mat = Contraption["mat", array] Mod = Contraption["mod", array] Ang = Contraption["ang", array] Skin = Contraption["skin", array] I = 1 } } if (clk("vars")) { if (I <= Pos:count()) { Temp = propSpawn(Mod[I, string], Pos[I, vector], Ang[I, angle], 1) Temp:setColor(Color[I, vector4]) Temp:setMaterial(Mat[I, string]) Temp:setSkin(Skin[I, number]) if (I > 0) { Temp:weld(Con[1, entity]) } Con:pushEntity(Temp) I++ timer("vars", 250) } else { print("Finished " + Con:count() + " props spawned.") selfDestruct() } }
Comments
What I would do with the constraints is ignore what's welded to what and just set a parent prop flag in the save file, then weld everything to that (multi-weld style).