This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
Danie40411's profile picture

Help with multiple points please

Started by Danie40411, 27 September 2015 - 12:29 PM
Danie40411 #1
Posted 27 September 2015 - 02:29 PM
Literally started ComputerCraft 6 hours ago and have yet to finish my first program, I've just started recieving a multiple points error everytime I try to access gui by typing gui. Here is the code, hopefully it's not too difficult to find. Thanks for any help I recieve, I have very very little idea what I'm actually doing so far. And sorry, it's probably a bit longer than it needed to be, newb clutter.


–Variables
version = 1.0.0
running = true

–Colors
colTaskBar = colors.black
colBackground = colors.black


–Images
_dt = paintutils.loadImage("/os/.backgrounds/dt")


–Booleans
_ms = 0
_rcm = 0


–Functions
clear = function()
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1, 1)
end

drawMenu1 = function()
term.setCursorPos(1, 2)
term.setBackgroundColor( colors.red )
term.setTextColor( colors.black )
print( "[POWER]" )

end

rightClickMenu = function(x, y)
term.setBackgroundColor( colors.white )
term.setTextColor( colors.black )
term.setCursorPos(x, y)
term.write(" [LUA] ")
term.setCursorPos(x, y+1)
term.write(" [IDE] ")
local event, button, xPos, yPos = os.pullEvent("mouse_click")
while true do
if button == 1 and yPos == y and xPos <= (x+7) and xPos >= x then
running = false
clear()
term.setTextColor( colors.red )
print("Gone into Command Prompt..")
print("OS will shutdown after exitting of LUA PROMPT")
print("Any function of the OS is in the LUA functions now.")
shell.run("lua")
break
elseif button == 1 and yPos == (y+1) and xPos <= (x+7) and xPos >= x then
shell.run("edit", "/gui")
init()
break
else
redraw()
break
end
end
_rcm = 0
end


redraw = function()
drawDeskTop()
drawTaskBar()
end

drawTaskBar = function()
term.setCursorPos(1, 1)
term.setBackgroundColor( colors.colTaskBar )
term.clearLine()
term.setCursorPos(1, 1)
term.setBackgroundColor( colors.black )
term.setTextColor( colors.white )
term.write( "[MENU]" )
end

drawDeskTop = function()
term.setBackgroundColor(colors.colBackground)
term.clear()
term.setCursorPos(1, 1)
paintutils.drawImage(_dt, 1, 1)
end



loadConfig = function()
local
end



stop = function()
clear()
running = false
term.setTextColor( colors.green )
print("Log Off Confirmed.")
exit()
end

runTime = function()
while running do
event, button, x, y = os.pullEvent("mouse_click")
if _ms == 0 and button == 1 and x < 7 and y == 1 then
drawMenu1()
_ms = 1
elseif _ms == 1 and button == 1 and y == 2 and x < 7 then
stop()
elseif _ms == 1 and button == 1 and x < 7 and y == 1 then
init()
elseif _ms == 0 and _rcm == 0 and button == 2 then
_rcm = 1
rightClickMenu(x, y)

end
end
end


init = function()
_ms = 0
drawDeskTop()
drawTaskBar()
runTime()
end

–Main Stuff

init()
Lyqyd #2
Posted 27 September 2015 - 06:28 PM
This error is covered in the Common Errors section of my favorite sticky post.
Exerro #3
Posted 27 September 2015 - 08:37 PM
Funny how the problem here is exactly the same as the example in the sticky.

Anyway, when you type 1.0.0, Lua thinks it's a number, but it has two decimal points!? No number can have two decimal points, so it errors. You'll probably want to contain it in a string like so: "1.0.0", or simply have a major and minor version like so: 1.0

If you go with the string option, you can get the individual components like this:

local major = tonumber( ver:match "^%d+" )
local minor= tonumber( ver:match "%.(%d+)" )
local patch = tonumber( ver:match "%d%.(%d+)" )

If you go with the number option, you can get the individual components like this:

local major = math.floor( ver )
local minor = ver % 1 * 100
local patch = 0 -- this isn't contained in the version number, so default to 0?

Edit: fixed code
Edited on 28 September 2015 - 05:09 PM
negamartin #4
Posted 27 September 2015 - 10:18 PM
Getting the minor with the string and number ways would return different values.

Using strings, 1.13.0 would return:
Major 1
Minor 13
Patch 0

Using numbers, 1.13 would return:
Major 1
Minor 0.13
Patch 0

Just pointing it out
Danie40411 #5
Posted 27 September 2015 - 11:51 PM
It was really that simple? Lmao
Thanks, guys. I think I may have been to tired to notice the issue.
And sorry for the duplicate thread.
TYKUHN2 #6
Posted 28 September 2015 - 12:00 AM

local minor = ver-major*100