65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 05:25 PM
can someone debug this code
error: bios:338: [string "startup"]:2: '<name>' expected
local input; --input
local 1 = "1"
local 2 = "2"
local 3 = "3"
local 4 = "4"
local 5 = "5"
function clear()
term.clear()
end
clear
print("Leocraft OS 1.0.0")
print("REWRITTEN")
function drawMenu()
clear()
print("1-5")
input = read( )
end
drawMenu()
if input = 1 then
print("Shell")
print("'back' to go back")
shell.run("shell")
elseif input = 2 then
shell.run("reboot")
elseif input = 3 then
shell.run("shutdown")
elseif input = 5 then
shell.run("worm")
elseif input = 4 then
shell.run("adventure")
else
drawMenu()
thanks
Edited on 01 July 2014 - 04:35 PM
105 posts
Posted 01 July 2014 - 05:29 PM
You can not use a number as a variable.
you should do:
number1="1"
etc.
instead of
1="1"
Edited on 01 July 2014 - 03:29 PM
65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 05:40 PM
thanks oh ive prereleased this its Leocraft OS in operating systems
error: bios:338: [string "startup"]:28: 'then' expected
please help debug this it will help i did NanoBob's help so change that for now
105 posts
Posted 01 July 2014 - 05:50 PM
Couple things, if you check a something in an if or elseif statement use
if i==1 then
end
not
if i=1 then
end
Also your elseif statement near the end of the file
Spoiler
This one:
if input = 1 then
print("Shell")
print("'back' to go back")
shell.run("shell")
elseif input = 2 then
shell.run("reboot")
elseif input = 3 then
shell.run("shutdown")
elseif input = 5 then
shell.run("worm")
elseif input = 4 then
shell.run("adventure")
else
drawMenu()Misses an end.
65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 05:51 PM
Couple things, if you check a something in an if or elseif statement use
if i==1 then
end
not
if i=1 then
end
Also your elseif statement near the end of the file
Spoiler
This one:
if input = 1 then
print("Shell")
print("'back' to go back")
shell.run("shell")
elseif input = 2 then
shell.run("reboot")
elseif input = 3 then
shell.run("shutdown")
elseif input = 5 then
shell.run("worm")
elseif input = 4 then
shell.run("adventure")
else
drawMenu()Misses an end.
where do i put the end
105 posts
Posted 01 July 2014 - 05:53 PM
Couple things, if you check a something in an if or elseif statement use
if i==1 then
end
not
if i=1 then
end
Also your elseif statement near the end of the file
Spoiler
This one:
if input = 1 then
print("Shell")
print("'back' to go back")
shell.run("shell")
elseif input = 2 then
shell.run("reboot")
elseif input = 3 then
shell.run("shutdown")
elseif input = 5 then
shell.run("worm")
elseif input = 4 then
shell.run("adventure")
else
drawMenu()Misses an end.
where do i put the end
You put it at the end of the if statement.
if i==something then
--code
elseif i==somethingElse then
--code
else
--code
end
^ An example of an if statement
65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 05:55 PM
thanks
it prints near middle lines
why
105 posts
Posted 01 July 2014 - 05:57 PM
Could you update your code so I can look at it? And please give a better explanation of your problem
65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 06:06 PM
pastebin get 56xf1c6x
run above and debug, put on pastebin and give me code please
there you go
thats updated
thanks
Edited on 01 July 2014 - 04:05 PM
105 posts
Posted 01 July 2014 - 06:07 PM
This paste has been removed, and I'm unable to gon ingame so can't debug. just tell me what the problems are and errors you get
65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 06:10 PM
that the best i can do
how do i copy in game
65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 06:21 PM
local input; --input
local shell = "1"
local reboot = "2"
local shutdown = "3"
local adventure = "4"
local worm = "5"
function clear()
term.clear()
end
clear()
print("Leocraft OS 1.0.0")
print("REWRITTEN")
function drawMenu
clear()
print("1-5")
input = read( )
end
drawMenu()
if input == shell then
print("shell")
print("type 'back' to go back")
shell.run("Shell")--error
elseif input == reboot then
shell.run("reboot")--error
elseif input == shutdown then
shell.run("shutdown")--error
elseif input == worm then
shell.run("worm")--error
elseif input == adventure then
shell.run("adventure")--error
else
drawMenu()
end
errors when i do programs in shell.run("program")
Edited on 01 July 2014 - 04:34 PM
65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 06:37 PM
this is in tekkit lite fyi
105 posts
Posted 01 July 2014 - 06:44 PM
you have a capital S in shell.
65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 07:28 PM
oh typo i looked in minecraft its correct ignore that
8543 posts
Posted 01 July 2014 - 07:30 PM
You blasted away the shell "API" on line two of the code above. You can't expect it to hold two values at once, so it will either hold "1" (or whatever other value you gave it), or it will hold the table of functions (including the run function you try to call later), but not both at once.
65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 07:40 PM
You blasted away the shell "API" on line two of the code above. You can't expect it to hold two values at once, so it will either hold "1" (or whatever other value you gave it), or it will hold the table of functions (including the run function you try to call later), but not both at once.
what do you mean i do not get what you said
its suposed to when you type 1 this.
Quick Shell
Type 'back' to go back
CraftOS 1.5
>_
when 2 restart 3 shutdown 4 run adventure 5 run worm
anyone can help
you can look at prerelase in operating systems/Leocraft OS
65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 07:48 PM
fixed: near middle printing
bug: type invalid then again starts blinking again
fixed: nothing works
added: can also type program name to run the error,LOL.
bug: when typeing out the program its invalid
bug: invalid > correct input wont read
Edited on 01 July 2014 - 06:18 PM
105 posts
Posted 01 July 2014 - 07:56 PM
You blasted away the shell "API" on line two of the code above. You can't expect it to hold two values at once, so it will either hold "1" (or whatever other value you gave it), or it will hold the table of functions (including the run function you try to call later), but not both at once.
what do you mean i do not get what you said
In the begining of your proghrams you assign shell to be "1". And by default shell is a table holding certain functions from the shell API, so by defining shell as a string you can no longer use those functions.
65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 08:11 PM
ok
65 posts
Location
I am a hidden viuris on your computer
Posted 01 July 2014 - 08:16 PM
bug: wont read if u do an invalid then a correct
7508 posts
Location
Australia
Posted 02 July 2014 - 02:30 AM
have you tried to fix it yourself?
Here in Ask a Pro, the effort people are willing to expend helping you is usually about equal to the effort you are putting in.
Edited on 02 July 2014 - 12:30 AM
65 posts
Location
I am a hidden viuris on your computer
Posted 02 July 2014 - 06:53 PM
yeah
fixed: near middle printing <– fixed on my own w/o help
bug: type invalid then again starts blinking again
fixed: nothing works
added: can also type program name to run the error,LOL.
bug: when typeing out the program its invalid
bug: invalid > correct input wont read
65 posts
Location
I am a hidden viuris on your computer
Posted 03 July 2014 - 12:18 AM
bios:338: [string "startup"]:54: 'end' expected (to close 'function' at line 34)
line 34 is
function readUsersInput()
14 posts
Posted 03 July 2014 - 03:42 AM
You need to close a function with "end" just as you would with an if statement.
function foobar()
--foo
--bar
--baz
end --This is what your're missing
Please read Lua's official website (
www.lua.org) for more information, as it seems this thread has become one for people to solve all your problems. Don't get me wrong; I (and I'm sure many others here) enjoy helping people, but as this sub-forum and it's populace has stated many times:
Here in Ask a Pro, the effort people are willing to expend helping you is usually about equal to the effort you are putting in.
598 posts
Location
The United States
Posted 03 July 2014 - 04:02 AM
I'm sorry, but if you know this little about Lua and need this much help, you really shouldn't be writing an Operating System.
14 posts
Posted 03 July 2014 - 04:07 AM
I'm sorry, but if you know this little about Lua and need this much help, you really shouldn't be writing an Operating System.
You have to start somewhere. I'm not saying everyone should start with an OS (especially if they have no previous programming experience), but it's a good way to learn the basics of CC (and by extension Lua), even if the result isn't all that great.
Edited on 03 July 2014 - 02:08 AM
598 posts
Location
The United States
Posted 03 July 2014 - 03:07 PM
I'm sorry, but if you know this little about Lua and need this much help, you really shouldn't be writing an Operating System.
You have to start somewhere. I'm not saying everyone should start with an OS (especially if they have no previous programming experience), but it's a good way to learn the basics of CC (and by extension Lua), even if the result isn't all that great.
Yes, everyone has to start somewhere, but trying to run before you can even crawl is a terrible, terrible idea. I suggest that the OP puts aside his Operating System for now, and works on some more simple programs before he comes back to this.
65 posts
Location
I am a hidden viuris on your computer
Posted 03 July 2014 - 06:17 PM
You need to close a function with "end" just as you would with an if statement.
function foobar()
--foo
--bar
--baz
end --This is what your're missing
Please read Lua's official website (
www.lua.org) for more information, as it seems this thread has become one for people to solve all your problems. Don't get me wrong; I (and I'm sure many others here) enjoy helping people, but as this sub-forum and it's populace has stated many times:
Here in Ask a Pro, the effort people are willing to expend helping you is usually about equal to the effort you are putting in.
1. i have tried
2. i have an end
and another im working on this for fun it may an probaly will stop getting updates. so im not working on this 24/7. more like 2/5.
oh and this is not my first program. ive made a movie theatre with computercraft and it works 100%
65 posts
Location
I am a hidden viuris on your computer
Posted 03 July 2014 - 06:25 PM
the thing is, it looks fine to me!
14 posts
Posted 03 July 2014 - 06:35 PM
the thing is, it looks fine to me!
Then can you please post the entire file here?
[Edit]: In <CODE></CODE> tags (replace the "<>" with "[]").
Edited on 03 July 2014 - 04:44 PM
65 posts
Location
I am a hidden viuris on your computer
Posted 03 July 2014 - 07:03 PM
local input; --input
local leo = "1"
local reboot = "2"
local shutdown = "3"
local adventure = "4"
local worm = "5"
function clear()
term.clear()
end
clear()
term.setCursorPos(1,1)
print("Leocraft OS 1.1.0 beta")
print("by Leotomas")
sleep(2)
function drawMenu()
clear()
term.setCursorPos(1,1)
term.setTextColor(colors.lime)
print("1-5") --5 lines after this are print() then 1. shell etc
term.setTextColor(colors.yellow)
print("Ver 1.1.0")
input = read()
readUsersInput()
end
function readUsersInput()
if input == leo then
print("shell")
shell.run("shell")
else
print("hi")
end
now done!
Edited on 03 July 2014 - 11:36 PM
8543 posts
Posted 03 July 2014 - 07:39 PM
And what is the full text of the error message when you run that exact code?
14 posts
Posted 03 July 2014 - 07:48 PM
local input; --input
local leo = "1"
local reboot = "2"
local shutdown = "3"
local adventure = "4"
local worm = "5"
function clear()
term.clear()
end
clear()
term.setCursorPos(1,1)
print("Leocraft OS 1.1.0 beta")
print("by Leotomas")
sleep(2)
function drawMenu()
clear()
term.setCursorPos(1,1)
term.setTextColor(colors.lime)
print("1-5") --5 lines after this are print() then 1. shell etc
term.setTextColor(colors.yellow)
print("Ver 1.1.0")
input = read()
readUsersInput()
end
to be completed
You need to end a function before you define a second one. In this case, you make a function called "drawMenu", but you don't end it before you try to make a second one "readUserInput"I withdraw my statement.
Edited on 03 July 2014 - 08:04 PM
1220 posts
Location
Earth orbit
Posted 03 July 2014 - 07:55 PM
He isn't 'making' readUserInput(), he's calling it as if it already exists, but it doesn't exist since it's not defined/created anywhere. In addition to that, there *appears* to be at least one other error in the code that I can see.
I defer to Lyqyd's question.
8543 posts
Posted 03 July 2014 - 09:06 PM
He's also just plain wrong. You can define functions within other functions just fine.
65 posts
Location
I am a hidden viuris on your computer
Posted 04 July 2014 - 01:37 AM
im calling drawMenu() after i make the readUsersInput()
i can do pastebin
c0untQe7
14 posts
Posted 04 July 2014 - 01:56 AM
im calling drawMenu() after i make the readUsersInput()
i can do pastebin
c0untQe7
You are ending the "if" block in readUsersInput(), but not the function itself. It should be this:
function readUsersInput()
if input == leo then
print("Quick Shell")
print("Type 'back' to go back")
shell.run("shell")
elseif input == reboot then
shell.run("reboot")
elseif input == shutdown then
shell.run("shutdown")
elseif input == worm then
shell.run("worm")
elseif input == adventure then
shell.run("adventure")
else
drawMenu()
end --You just had this one originally; this ends the if block
end--This one ends the function
He's also just plain wrong. You can define functions within other functions just fine.
Oh…I don't know what posessed me to believe that. I was aware you could do it in other languages, but it just didn't click then :P/>
65 posts
Location
I am a hidden viuris on your computer
Posted 04 July 2014 - 06:33 PM
works thanks I'm releasing the update now.installer error: bios:338: [string "install"]:1: unexpected symbol
code is:
1 = shell.run("pastebin get code1 startup") --*code1 is not the code
2 = shell.run("pastebin get code2 os") --*
3 = shell.run("pastebin get code3 back") --*
1
2
3
if 1 == true and 2 == true and 3 == true then
shell.run("clear")
print("Success. Now rebooting")
sleep(2)
shell.run("reboot")
else
print("Failed. Check your internet connection, and try again")
end
print("oh man i please help")
if help == true then
print("thanks")
else
print("why no help")
end
textutils.slowPrint("LOL")
LOL
14 posts
Posted 04 July 2014 - 06:39 PM
You can't assign numbers as variables.
I'm not certain, but it looks like you're trying to check if you can reach these places before you download stuff.
Try:
if http then
print("Installing")
shell.run("pastebin","get", "PASTEBIN LINK", "back")
shell.run("pastebin","get","LINK","os")
shell.run("pastebin","get","LINK","startup")
print("Installed successfully!")
sleep(1)
shell.run("startup")
else
print("HTTP is not enabled.")
end
This was on a phone, so forgive typos.
65 posts
Location
I am a hidden viuris on your computer
Posted 04 July 2014 - 06:41 PM
thanks
help == true