Tabletop Simulator

Tabletop Simulator

View Stats:
Ruttsah Aug 22, 2022 @ 9:29pm
Making a save/load map script
So I'm working on the tabletop mod for the Wargame If Worlds Collide, and I wanna make it easier for players to load in maps rather than having to sub to more workshop mods.

Anyone who's played Star Wars Legion on TTS is aware of how friggin amazing that mod is with its scripting and map loading features.

I don't wanna go that in depth yet, but just making something that can "Save" the board layout of a specified area and then load from the token its saved too would be good.

How would I go about doing? I have no knowledge of scripting in TTS. Is this gonna be beyond me and I should just pay someone who knows how to do it or is it possible for me to figure out on my own?
< >
Showing 1-1 of 1 comments
Finaryman Aug 24, 2022 @ 12:01am 
i have script that can save selected objects to item
function onChat(message, sender)
if message == "#luosetti" and sender.host then
local selobjs=sender.getSelectedObjects()
if #selobjs > 0 then
local spawnpos=selobjs[#selobjs].getPosition()
local spawnrot=selobjs[#selobjs].getRotation()
local tmpdesc=selobjs[#selobjs].getDescription()
local list={}
for i=1, #selobjs-1 do
table.insert(list,selobjs[i].getData())
end
local txtdata=JSON.encode(list)
local tmpobjdata={}
tmpobjdata.Name= "BlockSquare"
tmpobjdata.Description="save"
tmpobjdata.Memo=txtdata
tmpobjdata.Transform={}
tmpobjdata.Transform.posX=spawnpos.x
tmpobjdata.Transform.posY=spawnpos.y
tmpobjdata.Transform.posZ=spawnpos.z
tmpobjdata.Transform.rotX=spawnrot.x
tmpobjdata.Transform.rotY=spawnrot.y
tmpobjdata.Transform.rotZ=spawnrot.z
tmpobjdata.Transform.scaleX=1
tmpobjdata.Transform.scaleY=1
tmpobjdata.Transform.scaleZ=1
tmpobjdata.LuaScript="function onLoad() self.addContextMenuItem('Lataa', function() local list=JSON.decode(self.memo); for i=1,#list do spawnObjectData({data=list[i], position=self.positionToWorld(Vector(list[i].Transform.posX,list[i].Transform.posY,list[i].Transform.posZ)), rotation=Vector(list[i].Transform.rotX+self.getRotation().x,list[i].Transform.rotY+self.getRotation().y,list[i].Transform.rotZ+self.getRotation().z), }); end self.destruct(); end ) end"
spawnObjectData({data=tmpobjdata})
end
end
end
as intructions how to use

1. spawn redcube
2. select restof objects
3. select cube spawned
4. ---
or
2. select all
3. deselect redcube
4. reselect redcube

5.type to chat #luosetti

things to remember
-leave red cube before command at 0 rotation
-when u use red cube to load objects, leave red cube 0 rotation.
-if u want to rotate objects then when u load rotate accordingly.
Last edited by Finaryman; Nov 3, 2022 @ 5:26am
< >
Showing 1-1 of 1 comments
Per page: 1530 50