Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function onLoad()
- storageBagGUID = '259c8c'
- storageBag = getObjectFromGUID(storageBagGUID)
- self.createButton({
- click_function = 'export',
- function_owner = self,
- label = 'Export',
- position = {0,0.25,0.7},
- scale = {0.3,0.3,0.3},
- width = 1100,
- height = 400,
- font_size = 360,
- font_color = {0.9,0.9,0.9},
- color = {0.1,0.1,0.1},
- tooltip = 'Export:\nLeft Click - Print Table\nRight Click = Print and Store table\nTable buttons:\nLeft Click - Deploy Table\nRight Click - Store Table'
- })
- buildTables()
- end
- --This will export the table of the current setup to the notepad tool.
- function export(obj, player_clicker_color, alt_click)
- hitList = Physics.cast({
- origin = {0, 4.06, 0},
- direction = {0,1,0},
- type = 3,
- size = {31.24, 5.10, 31.78},
- max_distance = 0,
- debug = true,
- }) -- returns {{Vector point, Vector normal, float distance, Object hit_object}, ...}
- --Begins to build the data export
- local note = 'tableName = {\n'
- for _, entry in ipairs(hitList) do
- obj = entry.hit_object
- printGUID = obj.getGUID()
- printPos = obj.getPosition()
- printRot = obj.getRotation()
- --Adds the guid to note
- note = note .. '\t{guid="'
- note = note .. obj.getGUID()
- --Adds the posision to note
- note = note .. '", pos={'
- note = note .. round(printPos.x,2) .. ","
- note = note .. round(printPos.y,2) .. ","
- note = note .. round(printPos.z,2) .. "}"
- --Adds the rotation to note
- note = note .. ', rot={'
- note = note .. round(printRot.x,2) .. ","
- note = note .. round(printRot.y,2) .. ","
- note = note .. round(printRot.z,2) .. "}"
- --Adds the lock state to the note
- note = note .. ', lock='
- if obj.getLock() == true then
- note = note .. "true},\n"
- else
- note = note .. "false},\n"
- end
- if alt_click == true then
- Wait.time(|| storageBag.putObject(entry.hit_object), 0.5)
- end
- end
- --Add the final tag to the end of the table
- note = note .. "\n},"
- --Sends the final results of note to the notepad tool
- setNotes(note)
- end
- function table01(obj, player_clicker_color, alt_click)
- selectedTable = dataTables[self.getButtons()[2].tooltip]
- if alt_click != true then
- deploy(selectedTable)
- else
- store(selectedTable)
- end
- end
- function table02(obj, player_clicker_color, alt_click)
- selectedTable = dataTables[self.getButtons()[3].tooltip]
- if alt_click != true then
- deploy(selectedTable)
- else
- store(selectedTable)
- end
- end
- function table03(obj, player_clicker_color, alt_click)
- selectedTable = dataTables[self.getButtons()[4].tooltip]
- if alt_click != true then
- deploy(selectedTable)
- else
- store(selectedTable)
- end
- end
- function deploy(objTable)
- for _, entry in pairs(objTable) do
- storageBag.takeObject({
- position = entry.pos,
- rotation = entry.rot,
- callback_function = function(obj) obj.setLock(entry.lock) end,
- smooth = false,
- guid = entry.guid
- })
- end
- end
- function store(objTable)
- for _, entry in pairs(objTable) do
- storageBag.putObject(getObjectFromGUID(entry.guid))
- end
- end
- function buildTables()
- dataTables = {
- ['comp'] = {
- {guid="a7b0f4", pos={-7.84,3.66,8.05}, rot={0,180,0}, lock=false},
- {guid="8984d3", pos={-6,3.66,12}, rot={0,180,0}, lock=false},
- {guid="4f6282", pos={0,1.49,0.02}, rot={0,0,0}, lock=false},
- {guid="3abc95", pos={8,3.66,8}, rot={0,180,0}, lock=false},
- {guid="fdcc18", pos={6,3.66,12}, rot={0,180,0}, lock=false},
- {guid="c4b11b", pos={0.18,3.66,14.02}, rot={0,180,0}, lock=false},
- {guid="ba04fe", pos={0,1.48,0}, rot={0,180,0}, lock=true},
- {guid="6b3803", pos={8,3.66,-8}, rot={0,180,0}, lock=false},
- {guid="736109", pos={0,3.66,-14}, rot={0,180,0}, lock=false},
- {guid="3c8a64", pos={6,3.66,-12}, rot={0,180,0}, lock=false},
- {guid="589d44", pos={-8.13,3.66,-7.95}, rot={0,180,0}, lock=false},
- {guid="fc398c", pos={-6,3.66,-12}, rot={0,180,0}, lock=false},
- },
- ['coopGate'] = {
- },
- ['coopAi'] = {
- },
- }
- local i = 1
- for tableName, table in pairs(dataTables) do
- self.createButton({
- click_function = 'table0' .. i,
- function_owner = self,
- label = i,
- position = {0.8 , 0.25, -1.25 + i*0.25},
- scale = {0.3,0.3,0.3},
- width = 400,
- height = 400,
- font_size = 360,
- font_color = {0.9,0.9,0.9},
- color = {0.1,0.1,0.1},
- tooltip = tableName
- })
- i = i + 1
- end
- end
- --Round number (num) to the second decimal
- function round(num,dec)
- local mult = 10^(dec or 0)
- return math.floor(num * mult + 0.5) / mult
- end
RAW Paste Data