Advanced Altitude Markers
function onload()
--[[ print('Onload!') --]]
end
function buttonLua(size)
local buttonht = 0.65-(size*0.003)
return "local button_parameters = {}\r\nbutton_parameters.click_function = 'grow'\r\nbutton_parameters.label = '+'\r\nbutton_parameters.function_owner = self\nbutton_parameters.position = {0.3," .. buttonht .. ", 0.3}\r\nbutton_parameters.rotation = {0, 0, 0}\r\nbutton_parameters.width = 200\r\nbutton_parameters.height = 200\r\nbutton_parameters.font_size = 150\nself.createButton(button_parameters)\n\nlocal button_parameters = {}\r\nbutton_parameters.click_function = 'shrink'\r\nbutton_parameters.label = '-'\r\nbutton_parameters.function_owner = self\nbutton_parameters.position = {-0.3," .. buttonht .. ", -0.3}\r\nbutton_parameters.rotation = {0, 0, 0}\r\nbutton_parameters.width = 200\r\nbutton_parameters.height = 200\r\nbutton_parameters.font_size = 150\nself.createButton(button_parameters)\n\nfunction grow()\n pos = self.getPosition()\n callLuaFunctionInOtherScriptWithParams(Global, 'grow',{pos['x'],pos['y'],pos['z'],self.getGUID()," .. size .. "})\nend\n\nfunction shrink(obj,player)\n pos = self.getPosition()\n callLuaFunctionInOtherScriptWithParams(Global, 'shrink',{pos['x'],pos['y'],pos['z'],self.getGUID()," .. size .. ",player})\nend"
end
function grow(params)
size=params[5]+1
if size >=16 then size=15 end
old=getObjectFromGUID(params[4])
old.destruct()
zone = { position = {params[1],params[2] + params[5] * 0.6, params[3]},
callback = 'doGrow',
type = 'ScriptingTrigger',
scale = {1,0.2,1},
params = { x=params[1], y=params[2], z=params[3],
size = size} }
spawnObject(zone)
end
function doGrow(zone, params)
yShift = 1
for _,o in ipairs(zone.getObjects()) do
local pos = o.getPosition()
pos.y = pos.y + yShift
pos[2] = pos.y
o.setPosition(pos)
end
zone.destruct()
size = params.size
local obj = {}
obj.type = 'Custom_Model'
obj.position = {params.x,params.y,params.z}
local spawned = spawnObject(obj)
local mesh = {}
mesh.mesh = 'http://infinitebucket.com/tts/dlance/altitude.obj'
mesh.material = 3
spawned.setCustomObject(mesh)
spawned.setScale({1,size,1})
spawned.setLuaScript(buttonLua(size))
spawned.setName(size)
spawned.setColorTint({127/255,(230-(size*10))/255,245/255})
end
function shrink(params)
size=params[5]-1
if size < 1 then
if params[6] ~= nil then
sendHome(getObjectFromGUID(params[4]), params[6])
return
else size = 1 end --respawn the token if it still has old code, for modder's convenience
end
old=getObjectFromGUID(params[4])
old.destruct()
local obj = {}
obj.type = 'Custom_Model'
obj.position = {params[1],params[2],params[3]}
local spawned = spawnObject(obj)
local mesh = {}
mesh.mesh = 'http://infinitebucket.com/tts/dlance/altitude.obj'
mesh.material = 3
spawned.setCustomObject(mesh)
spawned.setScale({1,size,1})
spawned.setLuaScript(buttonLua(size))
spawned.setName(size)
spawned.setColorTint({127/255,(230-(size*10))/255,245/255})
end
function sendHome(obj, player)
local offset = 6.25
local startOffset = -5
local hand = Player[player].getPlayerHand()
local pos = {hand.pos_x + hand.trigger_forward_x * offset
, hand.pos_y + hand.trigger_forward_y * offset
, hand.pos_z + hand.trigger_forward_z * offset }
pos[1] = pos[1] + hand.trigger_right_x * startOffset
pos[3] = pos[3] + hand.trigger_right_z * startOffset
local zone = { position = pos,
callback = 'trySendHome',
type = 'ScriptingTrigger',
scale = {1, 5, 1},
rotation = {hand.rot_x, hand.rot_y, hand.rot_z},
params = { pos = pos, obj = obj
, right = {hand.trigger_right_x, hand.trigger_right_y, hand.trigger_right_z}} }
spawnObject(zone)
end
function trySendHome(zone, params)
if #zone.getObjects() < 1 then
params.obj.setPositionSmooth(params.pos)
else
local offset = 2.5
params.pos[1] = params.pos[1] + params.right[1] * offset
params.pos[2] = params.pos[2] + params.right[2] * offset
params.pos[3] = params.pos[3] + params.right[3] * offset
local newZone = { position = params.pos, callback = 'trySendHome', type = 'ScriptingTrigger'
, rotation = zone.getRotation(), scale = zone.getScale(), params = params}
spawnObject(newZone)
end
zone.destruct()
end