Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function get_name()
- return "BUG REPORT"
- end
- function get_description()
- return {
- "*messy* is what happens when you use non-number keys. I wouldn't actually expect it to work.",
- "*outOfOrder* is an input which I attempted to fill backwards. It didn't work out.",
- "*outOfOrder2*, *outOfOrder3* and *outOfOrder4* are copies of *outOfOrder*"
- }
- end
- function get_board()
- return [[
- ..................
- ..................
- ..................
- ..................
- ....0.1.2.3.4.5...
- ..................
- ..................
- ]]
- end
- function get_data()
- outOfOrder = {}
- outOfOrder[4] = 4
- outOfOrder[3] = 3
- outOfOrder[2] = 2
- outOfOrder[1] = 1
- -- This becomes 4, 3, 2, 1 rather than 1, 2, 3, 4
- copy1 = {}
- for i=1,#outOfOrder do
- copy1[i] = outOfOrder[i]
- end
- -- This ends up getting properly set (1,2,3,4), as outOfOrder should've been
- copy2 = {}
- for k,v in pairs(outOfOrder) do
- copy2[k] = v
- end
- -- But this doesn't (4,3,2,1)
- copy3 = {}
- for k,_ in pairs(outOfOrder) do
- copy3[k] = outOfOrder[k]
- end
- -- And neither does this (4,3,2,1)
- -- And here's a more extreme example
- nonNumberKeys = {}
- nonNumberKeys["foo"] = 1 -- Why does this work?
- nonNumberKeys["bar"] = 2 -- This should be a COMPILE ERROR, no?
- nonNumberKeys["baz"] = 3
- nonNumberKeys[99] = 4
- nonNumberKeys[98] = 5
- nonNumberKeys[98] = 6 -- Actually manages to overwrite the 5
- nonNumberKeys[3] = 7 -- Doesn't overwrite anything.
- nonNumberKeys[2] = 8 -- Doesn't overwrite anything either.
- -- In the end, this becomes 1,2,3,4,6,7,8
- -- Adding packets to the timeline out of order works fine, though
- whatOfTheTimeline = {}
- whatOfTheTimeline[3] = {3}
- whatOfTheTimeline[2] = {2}
- whatOfTheTimeline[1] = {1}
- -- whatOfTheTimeline["cabbage"] = {0} -- COMPILE ERROR, as you'd expect
- create_terminal("non-numbers", "0", TYPE_XBUS, DIR_INPUT, {nonNumberKeys})
- create_terminal("outOfOrder", "1", TYPE_XBUS, DIR_INPUT, {outOfOrder})
- create_terminal("outOfOrder2", "2", TYPE_XBUS, DIR_INPUT, {copy1})
- create_terminal("outOfOrder3", "3", TYPE_XBUS, DIR_INPUT, {copy2})
- create_terminal("outOfOrder4", "4", TYPE_XBUS, DIR_INPUT, {copy3})
- create_terminal("timeLineTest", "5", TYPE_XBUS, DIR_INPUT, whatOfTheTimeline)
- end
Advertisement
Add Comment
Please, Sign In to add comment