Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function table.val_to_str ( v )
- if "string" == type( v ) then
- v = string.gsub( v, "\n", "\\n" )
- if string.match( string.gsub(v,"[^'\"]",""), '^"+$' ) then
- return "'" .. v .. "'"
- end
- return '"' .. string.gsub(v,'"', '\\"' ) .. '"'
- else
- return "table" == type( v ) and table.tostring( v ) or
- tostring( v )
- end
- end
- function table.key_to_str ( k )
- if "string" == type( k ) and string.match( k, "^[_%a][_%a%d]*$" ) then
- return k
- else
- return "[" .. table.val_to_str( k ) .. "]"
- end
- end
- function table.tostring( tbl )
- local result, done = {}, {}
- for k, v in ipairs( tbl ) do
- table.insert( result, table.val_to_str( v ) )
- done[ k ] = true
- end
- for k, v in pairs( tbl ) do
- if not done[ k ] then
- table.insert( result,
- table.key_to_str( k ) .. "=" .. table.val_to_str( v ) )
- end
- end
- return "{" .. table.concat( result, "," ) .. "}"
- end
- while 1 do
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- local foo = turtle.inspect()
- if foo == true or foo == false then
- print(foo)
- else
- print(table.tostring(foo))
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement