Jump to content




Error - bios:366: [string "GoCraftOS"]:163: unexpected symbol

computer utility

1 reply to this topic

#1 10Goody12

  • New Members
  • 2 posts

Posted 21 July 2016 - 07:19 AM

Hello.
I am new to the forums, and I am also new to Lua, relatively speaking.

The Big Picture
The big picture for the program I am trying to make, is a very ambitious project. I want to make an operating system.
And I want to make it mostly for learning purposes. I want to learn how and what commands and features can be used for
something useful or interesting. None of this has been copied off of anything, unless you consider referring to examples on the wikipedia page as plagiarism. Most of it has been done on a public server. It's a modpack server, and people were talking about why the mod was added if it was rather complicated or "useless" and I decided to look into it further.

Turns out, there is more than meets the eye.

Where did I look for help?
A handful of the people on the server know and understand CC well, and one or two are fluent in it. I could not locate one of them, but I contacted everyone I could on the server. They tried to see what was wrong with it, and some went in and tried debugging it themselves. The person told me it was broken in an exaggerated manner. I have lost the code twice while making it and have had remake it. I also looked on the CC wiki, and downloaded some Lua learning apps on my phone. I looked at videos, and I referred to pages in the wiki, and I felt like I'd followed the rules properly, but I evidently did not.

What did it do properly before it stopped working?
So this code, before adding the problematic part, would do the following nicely (according to what I wanted it to do).

- Show startup screen.
- Loading bar (purely aesthetic).
- A sort of fine print at the bottom in case people would try to claim it as their own (because it will be used on a server).
- Draw the desktop.
- Print the current time in the bottom right (would not update unless program restarted. A problem I could not figure out).
- Clickable "menu" button in the bottom left corner.
- A menu would open.
- Shutdown and Exit options would come up; the plan was to make them clickable, and they would turn the computer off, and exit the program, respectively.
- One of the buttons would work and then the others would not. At one point I made two work. The menu button and the exit button.
- If the menu button was to be clicked again, it would close the menu.

What do I want it to do, and what else do I want it to do from here?
I want the menu buttons to work. I tried to use functions to "streamline" the process, but I get the feeling that I have done it horrendously and that it made it sloppier. I feel like it's an improvement from codes I've made before, and it is still a WIP after all. What else do I want it to do? I want to be able to open programs from here, and then make a loop that checks if it is running, and then if it isn't, it will return to the desktop. Soon, I want to make a nice radiant background using number codes for colours. And finally, make it easy for people to make add-ons to it (optional).

What is it doing instead?
It is throwing errors at me saying that various "ifs" and "whiles" in the problematic area, have to be ended with "ends." The elseifs don't seem to be working properly, and when I tried to make the console check two variables with two values using "and" it did not work, so I had to extend it (otherwise "then expected," or "unrecognized symbol"). The section is supposed to control the menu button functions. So if one button is pressed, it should compare the vaues of the x and y coords of the click, and then execute the purpose of that button. Then elseif, check if the coords of the other button match with the coords of the click, and then execute the purpose of the second button.

What errors are coming up?
In chronological order of appearance and solution

1. "bios:366: [string "GoCraftOS"]:163: unexpected symbol"
2. ""

---- By: Goodle

-- Variables

width, height = term.getSize()

CnWidth = width / 2
CnHeight = height / 2

time = os.time()
formattedTime = textutils.formatTime( time, false)

isMenu = false
isDesktop = false
isStartup = false
		  
-- Functions

startup = function()
  isStartup = true
  term.clear()
  term.setCursorPos(CnWidth-5,height-1)
  term.setTextColour( colours.blue )
  term.write("WaffgoOS by")
  term.setCursorPos(CnWidth-20,height)
  term.write("Goodle Software - In cooperation with CPGGC")
  term.setCursorPos(CnWidth-3,CnHeight-1)
  term.setTextColour( colours.lightBlue )
  term.write("Loading")
  term.setCursorPos(CnWidth-6,CnHeight)
  term.write(";")
  term.setCursorPos(CnWidth+6,CnHeight)
  term.write(";")
  term.setBackgroundColour( colours.black )
  term.setCursorPos(CnWidth,CnHeight+1)
  term.write('0%')
  sleep(1)
  paintutils.drawLine(CnWidth-5,CnHeight, CnWidth,CnHeight, colours.green )
  term.setBackgroundColour( colours.black )
  term.setCursorPos(CnWidth-1,CnHeight+1)
  term.write("50%")
  sleep(0.5)
  paintutils.drawLine(CnWidth,CnHeight, CnWidth+4,CnHeight, colours.green )
  term.setBackgroundColour( colours.black )
  term.setCursorPos(CnWidth-1,CnHeight+1)
  term.clearLine()
  term.write("78%")
  sleep(0.3)
  term.setCursorPos(CnWidth-1,CnHeight+1)
  term.clearLine()
  term.write("80%")
  sleep(0.5)
  paintutils.drawLine(CnWidth+4,CnHeight, CnWidth+5,CnHeight, colours.green )
  term.setBackgroundColour( colours.black )
  term.setCursorPos(CnWidth-1,CnHeight+1)
  term.clearLine()
  term.write("100%")
  term.setCursorPos(CnWidth-3,CnHeight-1)
  term.clearLine()
  term.setBackgroundColour( colours.black )
  term.write("Welcome!")
  sleep(3)
  isStartup = false
  desktop()
end


desktop = function()

  isDesktop = true
  term.clear()
  pixelsDown = 1
  pixelsDownLimit = height
  -- Desktop drawing

  while pixelsDown ~= height
	do paintutils.drawLine(1,pixelsDown, width,pixelsDown, colours.white )
	pixelsDown = pixelsDown + 1
	end
  paintutils.drawLine(1,height, width,height, colours.blue )
  term.setCursorPos(1,height)
  term.setTextColour( colours.white )
  term.setBackgroundColour( colours.lime )
  term.write(' @ menu ')

  -- Clock Drawing

  term.setCursorPos(width-6,height)
  term.setTextColour( colours.white )
  term.setBackgroundColour( colours.blue )
  term.write(formattedTime)

  -- Text Input Impeder

  while isDesktop == true do
	term.setBackgroundColour( colours.white )
	term.setCursorPos(0,0)
	term.setCursorBlink(false)
	local event, click, x, y = os.pullEvent("mouse_click")
	if x == 2 then
	  if y == height then
	  break
	  end
	end
  end
end

drawWindow = function()
  term.clear()
end


drawMenu = function()
  isMenu = true
  local menuPD = 2 -- Menu pixels down
  local menuPDL = height-1 -- Menu pixels down limit
  local menuPUL = height-10 -- Menu pixels up limit
  -- Menu pixels right limit is = 15
  while menuPD < menuPDL do
	paintutils.drawLine(1, menuPUL, 15, menuPUL, 400 )
	menuPUL = menuPUL + 1
	menuPD = menuPD + 1
	end -- Dimensions of menu: w-15 from left, h-9 from height - 1
  term.setCursorPos(1,height)
  term.setTextColour( colours.white )
  term.setBackgroundColour( colours.green )
  term.write(" @ menu ")

  paintutils.drawLine(9,height, 15,height, colours.blue )
  term.setCursorPos(2,height-1)
  term.setBackgroundColour( 400 )
  term.setTextColour( colours.yellow )
  term.write("@ Exit") -- Logoff button
  term.setCursorPos(2,height-2)
  term.setTextColour( colours.red )
  term.write("@ Shutdown") -- Shutdown button

  term.setBackgroundColour( colours.white )
  menuButtons()

  while isMenu == true do
	local event, click2, x, y = os.pullEvent("mouse_click")
	if x ==  2 then
	  if y == height then
		isMenu = false
		desktop()
		break
	  end
	end
  end  
end

menuButtons = function() ------------------------------------------ Problems start
  while isMenu == true do
	local event, click3, x, y = os.pullEvent("mouse_click")
	if x == 2 then
	  if y == height-1 then
		isMenu = false
		isDesktop = false
		isStartup = false
		exit()
	elseif
	if x == 2 then ------------------------------------------------------ Line 163
	  if y == height-2 then
		os.shutdown()
	else
	  break
	  end
	end  
  end
end -------------------------------------------------------------------- Problems end
	
exit = function()
  term.clear()
  term.setBackgroundColour(colours.black)
  term.setTextColour(colours.white)
  term.setCursorPos(1,1)
  term.clear()
end
-- Program execution

startup()

drawMenu()

while isDesktop == true do
  drawMenu()  
  menuButtons()
end


#2 TYKUHN2

  • Members
  • 210 posts
  • LocationSomewhere in this dimension... I think.

Posted 21 July 2016 - 08:48 PM

Line 162 extra elseif

Replace with end or move line 163 up to it and remove the if

Edited by TYKUHN2, 21 July 2016 - 08:50 PM.






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users