Jump to content




wraithbone's GUI (CLI really...) Functions


  • You cannot reply to this topic
30 replies to this topic

#21 wraithbone

  • Members
  • 17 posts
  • LocationAuckland, New Zealand

Posted 20 January 2013 - 12:09 AM

View PostMegaMech, on 22 December 2012 - 06:59 AM, said:

I can't figure out the table for VertMenu()
I think you should add a bit more instructions to your post.
Otherwise, this is pretty cool, and looks clean... I'm probably gonna use it for a Stats Program I'm making. (Shows the status of all your industry's stuff)

table={"all","my","stuff"}
table2={"in","here","done"}
result = VertMenu(table)
result2 = Vertmenu(table2)
This makes it so if you select anything from table it shows everything from table2
how do I make it so if I choose "all" It shows table2 and if I choose "my" it shows everything from table3
or
if I choose "all" it shows table2[1] and if I choose "my" it shows table2[2]

You make use of an if statement
result = {}
if result[1] == this then
	result[2] = something
  
elseif result[1] == that then
	result[2] = something_else
  
elseif result[1] == other then
	result[2] = another_thing
  
end
if result[2] == even then
	result[3] = something_again
  
elseif result[2] == more then
	result[3] = something_new
  
elseif result[2] == things then
	result[3] = another_thing_entirely
  
end
--and so on and so forth....

Instead of making the result table equal to those made up variables, you can call the menu function to generate sub menus.

EDIT: In fact I get this question so often I have put some sample code under the VertMenu section (in a spoiler) to show how this might be done.

#22 pivotdude

  • Members
  • 7 posts

Posted 31 May 2013 - 02:45 AM

hey im trying to get the load bar to work on startup alongside my user login screen but i keep getting the following error :
bios:338: [string "startup"} :19: "=" expected

Here is my code

print("Prototype OS V0.01")
write("Login: ")
lanswer = read()
if lanswer == "Pivotdude" then
write("Password: ")
else
os.reboot()
end
panswer = read()
if panswer == "1337" then
print("Welcome "..lanswer..".")
else
os.reboot()
end
term.clear()
function HorzLoadBar(sx, fx, sym)
start x, finish x, "<symbol>"
end
function HorzLoadBar(sx, fx, sym)
x,y = term.getCursorPos()
if y >= 18 then
		term.clear()
		term.setCursorPos(sx,1)
		x,y = sx,1
end
term.setCursorPos(sx,y)
write("[")
term.setCursorPos(sx,y)
term.setCursorPos(fx-1,y)
write("]")
mdp = math.floor((sx + fx)/2) - 3
for i = (sx+1),(fx-2) do
		term.setCursorPos(i,y)
		write(sym)
		sleep(0.1) --CHANGE THIS TO EDIT TIME
		term.setCursorPos(mdp,y+1)
		write(string.format("%d",i/(fx-2) * 100))
		write("%")
end
term.setCursorPos(1,y+2)
end

EDIT: i am using the standard non advanced computer , should i be using the golden advanced one?
EDIT II: if i use brackets around the command in the function permameter its the same error except from the fact that ) is expected instead of =

#23 Tjakka5

  • Members
  • 256 posts

Posted 31 May 2013 - 02:09 PM

print("Prototype OS V0.01")
write("Login: ")
lanswer = read()
if lanswer == "Pivotdude" then
write("Password: ")
else
os.reboot()
end
panswer = read()
if panswer == "1337" then
print("Welcome "..lanswer..".")
else
os.reboot()
end
term.clear()
function HorzLoadBar(sx, fx, sym)
x,y = term.getCursorPos()
if y >= 18 then
		term.clear()
		term.setCursorPos(sx,1)
		x,y = sx,1
end
term.setCursorPos(sx,y)
write("[")
term.setCursorPos(sx,y)
term.setCursorPos(fx-1,y)
write("]")
mdp = math.floor((sx + fx)/2) - 3
for i = (sx+1),(fx-2) do
		term.setCursorPos(i,y)
		write(sym)
		sleep(0.1) --CHANGE THIS TO EDIT TIME
		term.setCursorPos(mdp,y+1)
		write(string.format("%d",i/(fx-2) * 100))
		write("%")
end
term.setCursorPos(1,y+2)
end

Try something like this, I dont have the time to test if it works now, but I noted that the function 'HorLoadBar' was in there twice, the 1 one causing the error.

#24 jesusthekiller

  • Banned
  • 562 posts
  • LocationWrocław, Poland

Posted 31 May 2013 - 06:16 PM

You don't say TUI...

You say CLI (Console Line Interface).
But even if you are using ASCII, it's still GUI.

#25 pivotdude

  • Members
  • 7 posts

Posted 01 June 2013 - 01:20 PM

Okay so i fixed it but i wanted to point out that i have not a single clue on what im doing since im new to CC however how would i center the login and the loadbar? i tried a general center function but it contradicts the other lines of code with multiple quoted brackets and stuff. also i am using notepad ++ to code (screw rewriting code - i did however do the loadbar 100% in CC prior to realising np++ read CC programs which can be seen by my mistake in the code)

#26 pivotdude

  • Members
  • 7 posts

Posted 03 June 2013 - 11:03 AM

I am sorry for double posting , but i am trying to get the windows style menu to work along side your loadbar and my login and system time on startup , i dont error but it refuses to show time and the menu (prepare for lots of code)

Loadbar:
Spoiler

Login:
Spoiler

System Clock:
Spoiler

Windows style menu:
Spoiler

Startup:
Spoiler

could someone please point ou what im doing wrong

#27 wraithbone

  • Members
  • 17 posts
  • LocationAuckland, New Zealand

Posted 26 June 2013 - 11:53 PM

View Postjesusthekiller, on 31 May 2013 - 06:16 PM, said:

You don't say TUI...

You say CLI (Console Line Interface).
But even if you are using ASCII, it's still GUI.
Thanks, I have changed the description.
Love the OP-Amp Avatar. =)
We all know that positive feedback just makes you unstable.

View Postpivotdude, on 03 June 2013 - 11:03 AM, said:

I am sorry for double posting , but i am trying to get the windows style menu to work along side your loadbar and my login and system time on startup , i dont error but it refuses to show time and the menu (prepare for lots of code)
<ABBREVIATED>
could someone please point ou what im doing wrong

Let me have a look.

#28 jesusthekiller

  • Banned
  • 562 posts
  • LocationWrocław, Poland

Posted 27 June 2013 - 11:50 AM

You googled it up or you already knew? :D

#29 Dave-ee Jones

  • Members
  • 456 posts
  • LocationVan Diemen's Land

Posted 03 July 2013 - 04:43 AM

Nice. Love the message box!

#30 wraithbone

  • Members
  • 17 posts
  • LocationAuckland, New Zealand

Posted 03 July 2013 - 05:20 AM

View Postjesusthekiller, on 27 June 2013 - 11:50 AM, said:

You googled it up or you already knew? :D

Sadly enough I already knew. One of the side affects of being an electrical engineer.

View PostAutoLocK, on 03 July 2013 - 04:43 AM, said:

Nice. Love the message box!

Thanks. Hope this makes your programs look good.

#31 wraithbone

  • Members
  • 17 posts
  • LocationAuckland, New Zealand

Posted 03 July 2013 - 05:25 AM

View Postpivotdude, on 03 June 2013 - 11:03 AM, said:

I am sorry for double posting , but i am trying to get the windows style menu to work along side your loadbar and my login and system time on startup , i dont error but it refuses to show time and the menu (prepare for lots of code)


Windows style menu:
Spoiler

could someone please point ou what im doing wrong

As far as I can tell the only thing that is missing here is that your menu program does not actually do anything. The function is there but you don't call it, or pass it anything.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users