Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Find the area and perimeter
- tArgs = {...}
- local mode = tArgs[1]
- local length = tArgs[2]
- local width = tArgs[3]
- local height = tArgs[4]
- local area = 0
- local stack64 = 0
- local stack16 = 0
- function calcArea3d(l,w,h)
- area = l * w * h
- stack64 = math.ceil(area / 64)
- stack16 = math.ceil(area / 16)
- end
- function calcArea2d(l,w)
- area = l * w
- stack64 = math.ceil(area / 64)
- stack16 = math.ceil(area / 16)
- end
- function report()
- local biggest = 0
- if #tostring(length) > biggest then biggest = #tostring(length) end
- if #tostring(width) > biggest then biggest = #tostring(width) end
- if #tostring(height) > biggest then biggest = #tostring(height) end
- print("================================")
- print(" Length: " .. string.rep(" ", biggest-#tostring(length)) .. length)
- print(" Width: " .. string.rep(" ", biggest-#tostring(width)) .. width)
- print(" Height: " .. string.rep(" ", biggest-#tostring(height)) .. height)
- print(" ------------------------------")
- biggest = 0
- local tmpArea = area .. " Blocks"
- local tmpStack64 = "~" .. stack64 .. " (x64)"
- local tmpStack16 = "~" .. stack16 .. " (x16)"
- if #tmpArea > biggest then biggest = #tmpArea end
- if #tmpStack64 > biggest then biggest = #tmpStack64 end
- if #tmpStack16 > biggest then biggest = #tmpStack16 end
- print(" Blocks Required: " .. string.rep(" ",biggest - #tmpArea ) .. tmpArea )
- print(" Stacks Required: " .. string.rep(" ",biggest - #tmpStack64) .. tmpStack64 )
- print(" Stacks Required: " .. string.rep(" ",biggest - #tmpStack16) .. tmpStack16 )
- print("================================")
- print("By zachdyer and da404lewzer.")
- end
- function help()
- end
- if mode == nil then
- print("help")
- elseif mode == "area3d" then
- if length == nil then
- help()
- elseif width == nil then
- width = length
- height = length
- calcArea3d(length,width,height)
- report()
- elseif height == nil then
- help()
- else
- calcArea3d(length,width,height)
- report()
- end
- elseif mode == "area2d" then
- if length == nil then
- help()
- elseif width == nil then
- width = length
- calcArea2d(length, width)
- report()
- else
- calcArea2d(length, width)
- report()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement