Sorroko / cclite

A cc emulator written in lua
33 stars 17 forks source link

term.write prints in wrong format #12

Open gamax92 opened 10 years ago

gamax92 commented 10 years ago

term.write supports any kind of type: However, the way it is printed is different:

tables will print "table: 0xADDRESS" instead of a serialized version of it. nil will cause an error, instead of printing nothing. numbers will print their tostring form, but they should be formatted to atleast the tens place. numbers with exponents will print in lowercase form, and have a + for positive numbers numbers with exponents also fail to print to atleast the tens place. EX 1e100 -> 1.0E100 numbers that evaluate to infinity will print "inf" instead of "Infinity" numbers that evaluate to -infinity will print "-inf" instead of "-Infinity" functions will print "function: 0xADDRESS" instead of nothing threads will print "thread: 0xADDRESS" instead of nothing

Examples:

Input Expected Received
nil native_api.lua:214: assertion failed!
42 42.0 42
1e100 1.0E100 1e+100
math.huge Infinity inf
-math.huge -Infinity -inf
{} {} table: 0xADDRESS
function() end function: 0xADDRESS
coroutine.create(function() end) thread: 0xADDRESS
gamax92 commented 10 years ago

I should mention that write and writeLine also have their input serialized, and not serializing it does infact break a program on the ComputerCraft forums (which is how I found that)