after some time I was finally brave enough to work on my turtle program again but came across an issue I can't figure out myself. The complete program: https://pastebin.com/fptxKN9n
Sorry for the title by the way, I don't know how to put it in a few words.
I basically just want to print out the table variables.ignor.
Spoiler
local variables = {"some irrelevant stuff",
["ignor"] = {"minecraft:stone", "minecraft:cobblestone", "minecraft:dirt", "minecraft:lava", "minecraft:flowing_lava", "minecraft:water", "minecraft:flowing_water"}
The custom function, although irrelevant for this thread since it works and I've used it for years:
Spoiler
function printWrapped(tab, xpos, ypos, Space, sep)
local sep = sep or " "
local leftSpace = Space
local newxpos = xpos
for word = 1, #tab do
if Space < #tab[word] + #sep then
return false
elseif leftSpace >= #tab[word]+#sep then
Sprint(tab[word]..sep, newxpos, ypos)
leftSpace = leftSpace - (#tab[word]+#sep)
newxpos = newxpos + #tab[word]+#sep
else
ypos = ypos + 1
leftSpace = Space
Sprint(tab[word]..sep, xpos, ypos)
leftSpace = leftSpace - (#tab[word]+#sep)
newxpos = xpos + (#tab[word]+#sep)
end
end
return ypos
end
function Sprint(str, xpos, ypos)
term.setCursorPos(xpos, ypos)
term.write(str)
end
function Splitter(inputstr, sep)
if inputstr == nil then
return nil
elseif sep == nil then
sep = " "
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
This function only takes a string as input, which is why I use textutils.serialize on my table before feeding it forward to the Splitter.My complete command looks like this:
printWrapped(Splitter(textutils.serialize(variables.ignor), '\n "minecraft:'), 18, 4, w-18)
And somewhere in here seems to be the mistake because instead of a somehow expected result, I get
{ s o , obbl s o , d , l v , low g_l v , w , low g_w , }
I hope you can show me what I did wrong and give a short explanation.
Thanks in advance,
Bruno