--find block position
local _POSITION_ = { commands.getBlockPosition() }
local tArgs = { ... }
local platform = {
vector.new( 0, 0, 0 ),
vector.new( 1, 0, 0 ),
vector.new( 0, 0, 1 ),
vector.new( 1, 0, 1 ),
vector.new( -1, 0, 0 ),
vector.new( 0, 0, -1 ),
vector.new( -1, 0, -1 ),
vector.new( 1, 0, -1 ),
vector.new( -1, 0, 1 ),
vector.new( 2, 0, 0 ),
vector.new( 0, 0, 2 ),
vector.new( -2, 0, 0 ),
vector.new( 0, 0, -2 ),
}
local function getPlayerPosition( p )
local success, t = commands.exec( "/tp " .. p .. " ~ ~ ~" )
if not success then
return false
end
local x, y, z = t[1]:match( "to (%-?%d+%.?%d*),(%-?%d+%.?%d*),(%-?%d+%.?%d*)" )
return math.floor( x ), math.floor( y ), math.floor( z )
end
local id = os.startTimer( 0.7 )
local p = {}
local function fillP()
for k, v in pairs( platform ) do
p[ k ] = v
end
end
local last = {}
local current = {}
local pos
local toExecute = {}
local function checkPlatform()
while #p > 0 do
local v = table.remove( p, #p )
local b = pos + v
local bstr = b:tostring()
local name = (last[bstr] and "glass") or commands.getBlockInfo( b.x, b.y, b.z ).name
if name == "minecraft:air" then
current[ bstr ] = b
if not last[ bstr ] then
toExecute[ #toExecute + 1 ] = "setblock " .. b.x .. " " .. b.y .. " " .. b.z .. " minecraft:glass"
end
elseif name == "glass" then
current[ bstr ] = b
end
end
end
while true do
local x, y, z = getPlayerPosition( "KingofGamesYami" )
pos = vector.new( x, y - 1, z )
local time = os.clock()
fillP()
parallel.waitForAll( checkPlatform, checkPlatform, checkPlatform, checkPlatform, checkPlatform )
for k, v in pairs( last ) do
if not current[ bstr ] then
toExecute[ #toExecute + 1 ] = "setblock " .. v.x .. " " .. v.y .. " " .. v.z .. " minecraft:air"
end
end
for k, v in pairs( toExecute ) do
commands.execAsync( v )
end
last = current
current = {}
toExecute = {}
print( os.clock() - time )
while true do
local event, tid = os.pullEvent( "timer" )
if id == tid then
break
end
end
id = os.startTimer( 0.7 )
end