E.g. split, encrypt, etc.
I'm gonna make a Library on them
local cPrint = function(text, ny) -- By GravityScore
if type(text) == "table" then for _, v in pairs(text) do centerPrint(v) end
else
local x, y = term.getCursorPos()
local w, h = term.getSize()
term.setCursorPos(w/2 - text:len()/2, ny or y)
print(text)
end
end
local x_pos = screen_width / 2 - #text_to_print / 2 + (#text_to_print % 2 == 0 and 1 or 0)
this formula ensures that the text always appears to be printed in the centre. since even length strings never look quite right when just using the standard centre formula, need to +1 onto their post to make it look nice. :)/>a string split should do the job…table.unconcat(<splitter>)
Unconcatenates a concatenated table back into a table. Does not work if concatenated with no splitter. I need this for CCCC Beta 1.1.
WHATEVERa string split should do the job…
split( stringFromTable, 'characterUsedWhenConcat')
only issue I can foresee is if you had a value in a table like say 'this, that' then you concat it with ', ' … the split would see that as 2 different entries… but there is no way around that, in any case, a string split is what you are after.
How is that at all relevant…?Also, Cloudy is looking at this topic…
I was just trying to help.WHATEVER
Exactly. a serialize/unserialize is good for when you need to transfer or process but be able to reverse it later… table.concat is good for displaying a table in a consistent format but there is just no reliable way to come back from it…But anyway, I don't really see a need for table.unconcat when you've got serialize/unserialize (limited though it may be, it is still more powerful than table.concat in terms of doing that sort of thing). I can understand how table.concat has its uses, but it still seems like an unconcat function has more limitations than it does advantages what with the issue you mentioned BIT.
make sure that when you calculate the x position you use this formula. Engineer must have an outdated ST2 plugin, because I'm pretty sure Grav added this formula after I told him too :P/>this formula ensures that the text always appears to be printed in the centre. since even length strings never look quite right when just using the standard centre formula, need to +1 onto their post to make it look nice. :)/>local x_pos = screen_width / 2 - #text_to_print / 2 + (#text_to_print % 2 == 0 and 1 or 0)
Great but I better write my own function. I don't have permission from GravityScore
only issue I can foresee is if you had a value in a table like say 'this, that' then you concat it with ', ' … the split would see that as 2 different entries… but there is no way around that, in any case, a string split is what you are after.
make sure that when you calculate the x position you use this formula. Engineer must have an outdated ST2 plugin, because I'm pretty sure Grav added this formula after I told him too :P/>this formula ensures that the text always appears to be printed in the centre. since even length strings never look quite right when just using the standard centre formula, need to +1 onto their post to make it look nice. :)/>local x_pos = screen_width / 2 - #text_to_print / 2 + (#text_to_print % 2 == 0 and 1 or 0)
make sure that when you calculate the x position you use this formula. Engineer must have an outdated ST2 plugin, because I'm pretty sure Grav added this formula after I told him too :P/>this formula ensures that the text always appears to be printed in the centre. since even length strings never look quite right when just using the standard centre formula, need to +1 onto their post to make it look nice. :)/>local x_pos = screen_width / 2 - #text_to_print / 2 + (#text_to_print % 2 == 0 and 1 or 0)
You asked me to add that? I never saw that. Adding it now anyway :P/>
It was in the centre write function that I gave you…You asked me to add that? I never saw that. Adding it now anyway :P/>
Kinda defeats the purpose of table.concat if you are going to start adding some kind of escapes for your code to pickup on unconcat. you may as well use textutils.serialize/unserialize, as your concat would be useless with random stuff in there….You could write your own concat function that always preceded any instances of the string to concat the table with with a \ or something. Then when un-concatenating, just check if the instance has a \ before it.
local t = {
'This',
'that',
'other.',
'good,',
'bad,',
'ugly',
}
print( table.concat( t, ' ' ) )
it would output thisThis that other. good, bad, ugly
This\ that\ other.\ good,\ bad,\ ugly
When was OS mentioned?Encryption is useful if you're making an OS.
When was OS mentioned?Encryption is useful if you're making an OS.
Or are you asking for an encryption function?
It wasn't. I am a random guy.How is that at all relevant…?
I accidentally held caps lock instead of shift on the W, so I'm sorry if it sounded rude. If it would've sounded rude anyway, I am also sorry, but I do have asperger's so it's… hard for me to communicate nicely…I was just trying to help.
I recommend using hash, since everyone has acces to the decrypt filesEncryption or hash? Maybe both?
No term.setCursorPos cause you can then manually clear the screen with spacesterm.clear() ?
function parity(number)
if number % 2 == 1 then
return false
else
return true
end
end
function colorWrite(text, x, y, color, bgColor)
color = color or colors.white
bgColor = bgColor or colors.black
term.setTextColor(color)
term.setBackgroundColor(bgColor)
term.setCursorPos(x, y)
term.write(text)
end
function refresh(background)
background = background or colors.black
term.clear()
term.setCursorPos(1, 1)
end
function mergeText(...)
local result = ""
for i = 2, #arg do
if i == #arg then
result = result .. arg[i]
else
result = result .. arg[i] .. arg[1]
end
end
return result
end