i have a file only the color red in it
FileColor
red
so now in another program i want to add this color like
fg = fs.open("loginSettins/version","r")
farbe = fg.readLine()
paintutils.drawPixel(1,5,colors.farbe)
fg.close()
it doesnt work what to do ?
file = fs.open ("aFile", "r")
print (file.readLine ()) --first line
print (file.readLine ()) -- second line
print (file.readLine ()) --you get the pattern...
...
file.close ()
Readline reads the next line, so calling readline multiple times will read diffrent lines.file = fs.open ("aFile", "r") print (file.readLine ()) --first line print (file.readLine ()) -- second line print (file.readLine ()) --you get the pattern... ... file.close ()
You can also use file.readAll () and split the text using string.split, I'm notgoing to put an example here becauze I'm on mobile right now.
local file = http.get( "URL_TO_RAW_PASTE_DATA" )
local data = file.readAll()
print( data )
local file = http.get("www.example.com")
local content = {}
for line in file.readLine do
table.insert(content, line)
end
And get specific lines such as line 3 with print(content[3])Could you not have made another topic altogether instead?
Anyways, colors.farbe does not exist in the colors api.
And since farbe is a string, you need to convert it into a number.
So paintutils.drawPixel(1,5, tonumber(farbe)) would be the way to go.
Could you not have made another topic altogether instead?
Anyways, colors.farbe does not exist in the colors api.
And since farbe is a string, you need to convert it into a number.
So paintutils.drawPixel(1,5, tonumber(farbe)) would be the way to go.
doenst work it always shows lightBlue
CodeSpoiler
shell.run"clear"
——————————————————
Bild = paintutils.loadImage("OS/d1.img")
paintutils.drawImage(Bild,1,1)
——————————————————
term.setBackgroundColor(colors.lightGray)
term.setTextColor(colors.white)
—–
fg = fs.open("loginSettins/version","r")
farbe = fg.readLine()
——————————————————
paintutils.drawPixel(49,17, colors.blue)
paintutils.drawPixel(50,18, colors.blue)
paintutils.drawPixel(50,17, colors.blue)
paintutils.drawPixel(49,18, colors.blue)
paintutils.drawPixel(48,17, colors.blue)
paintutils.drawPixel(48,18, colors.blue)
term.setTextColor(colors.gray)
term.setBackgroundColor(colors.white)
term.setCursorPos(1,7)
print("Settings")
term.setCursorPos(2,12)
print(" News")
term.setCursorPos(2,17)
print(" Worm")
term.setCursorPos(11,7)
print("ChromeMenu")
term.setCursorPos(13,12)
print("NPaint")
term.setCursorPos(13,17)
print("XFiles")
term.setTextColor(colors.white)
term.setBackgroundColor(colors.blue)
term.setCursorPos(48,17)
print("")
term.setCursorPos(48,18)
paintutils.drawPixel(3,4,40000)
paintutils.drawPixel(4,4,40000)
paintutils.drawPixel(5,4,40000)
paintutils.drawPixel(6,4,40000)
paintutils.drawPixel(3,5,40000)
paintutils.drawPixel(6,5,40000)
paintutils.drawPixel(3,6,40000)
paintutils.drawPixel(4,6,40000)
paintutils.drawPixel(5,6,40000)
paintutils.drawPixel(6,6,40000)
————
paintutils.drawPixel(3,9,3000)
paintutils.drawPixel(4,9,3000)
paintutils.drawPixel(5,9,3000)
paintutils.drawPixel(6,9,3000)
paintutils.drawPixel(3,10,3000)
paintutils.drawPixel(6,10,3000)
paintutils.drawPixel(3,11,3000)
paintutils.drawPixel(4,11,3000)
paintutils.drawPixel(5,11,3000)
paintutils.drawPixel(6,11,3000)
—————
paintutils.drawPixel(3,14,20000)
paintutils.drawPixel(4,14,20000)
paintutils.drawPixel(5,14,20000)
paintutils.drawPixel(6,14,20000)
paintutils.drawPixel(3,15,20000)
paintutils.drawPixel(6,15,20000)
paintutils.drawPixel(3,16,20000)
paintutils.drawPixel(4,16,20000)
paintutils.drawPixel(5,16,20000)
paintutils.drawPixel(6,16,20000)
————–
paintutils.drawPixel(14,4,33)
paintutils.drawPixel(15,4,33)
paintutils.drawPixel(16,4,33)
paintutils.drawPixel(17,4,33)
paintutils.drawPixel(14,5,33)
paintutils.drawPixel(17,5,33)
paintutils.drawPixel(14,6,33)
paintutils.drawPixel(15,6,33)
paintutils.drawPixel(16,6,33)
paintutils.drawPixel(17,6,33)
——————-
paintutils.drawPixel(14,9,17)
paintutils.drawPixel(15,9,17)
paintutils.drawPixel(16,9,17)
paintutils.drawPixel(17,9,17)
paintutils.drawPixel(14,10,17)
paintutils.drawPixel(17,10,17)
paintutils.drawPixel(14,11,17)
paintutils.drawPixel(15,11,17)
paintutils.drawPixel(16,11,17)
paintutils.drawPixel(17,11,17)
———————-
paintutils.drawPixel(14,14,9)
paintutils.drawPixel(15,14,9)
paintutils.drawPixel(16,14,9)
paintutils.drawPixel(17,14,9)
paintutils.drawPixel(14,15,9)
paintutils.drawPixel(17,15,9)
paintutils.drawPixel(14,16,9)
paintutils.drawPixel(15,16,9)
paintutils.drawPixel(16,16,9)
paintutils.drawPixel(17,16,9)
—————
paintutils.drawLine(1, 1, 51, 1, tonumber(farbe))
fg.close()
————
term.setTextColor(colors.white)
shell.run"cd //"
file = fs.open("loginSettins/curUser", "r")
version = file.readLine()
file.close()
term.setCursorPos(1,1)
print(version)
shell.run"cd //"
shell.run"cd OS"
term.setBackgroundColor(colors.lightGray)
term.setTextColor(colors.white)
local time = os.time()
local formattedTime = textutils.formatTime(time, false)
term.setCursorPos(44,1)
print(formattedTime)
color = "colors.red" -- this is what you are getting from the file
color = loadstring("return "..color)()
local fg = fs.open("loginSettins/version","r")
local farbe = fg.readLine()
paintutils.drawPixel(1,5,colors[farbe])
fg.close()
f = fs.open("file","r") file = {} i = 0 repeat curLine = f.readLine() if curLine == nil then else file[i] = curLine end until curLine == nil
local f = fs.open("file","r")
local file = {}
for line in f.readLine do
table.insert(file,line)
end
f.close()
Edit: Actually, jake, yours has a few types, you might want to check yours again
local file = {}
for line in io.lines("file") do table.insert(file,line) end
local myLine = io.lines("file")()
Did I really write it like that? I hope not, 'cause that won't work… you'd need to use f.readLine there, as opposed to f.readLine().
local myLine = io.lines("file")()
a
Boom OS right there