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

Can some one fix my Computer craft mainframe?

Started by Nom, 14 December 2013 - 02:06 AM
Nom #1
Posted 14 December 2013 - 03:06 AM
Hi im new to lua,
But I just spent 1 hour trying to make this advanced door system with a main frame (NMF) which has its own api!
The problem is I can't get the program to work properly.
Please can some one help fix the issues in the coding.
Here is the link to files: https://www.mediafire.com/?m8978z91ed54r38
Thanks,
Nom
nolongerexistant #2
Posted 14 December 2013 - 04:41 AM
You should really use Pastebin to upload your scripts. No one is going to download it from Mediafire.
Csstform #3
Posted 14 December 2013 - 09:54 AM
Alright. Let's see if I can help.

When you call

read("*")
it should be

read()

Also, after you call NFS.Start(), you have no way of seeing if the user typed either login or admin_login. I would suggest something like this:

i = 1
while i == 1 do
   input = read()
   if input == "login" then
      i = 0
      --code here
   elseif input == "admin_login" then
      i = 0
      --code here
   else
      print("Invalid input!")
   end
end
MKlegoman357 #4
Posted 14 December 2013 - 10:01 AM
When you call

read("*")
it should be

read()

Maybe he doesn't want anyone to see what he is typing?
Csstform #5
Posted 14 December 2013 - 10:08 AM
Aha! That's what it does! I've tried that so many times, and gotten an error each time though…
Nom #6
Posted 14 December 2013 - 01:39 PM
Alright. Let's see if I can help.

When you call

read("*")
it should be

read()

Also, after you call NFS.Start(), you have no way of seeing if the user typed either login or admin_login. I would suggest something like this:

i = 1
while i == 1 do
   input = read()
   if input == "login" then
      i = 0
      --code here
   elseif input == "admin_login" then
      i = 0
      --code here
   else
      print("Invalid input!")
   end
end
Yeah but that ruins the point of using a api.
Csstform #7
Posted 14 December 2013 - 03:59 PM
Didnt realize that was the API. Can you post the errors you are getting?
Nom #8
Posted 14 December 2013 - 04:15 PM
Didnt realize that was the API. Can you post the errors you are getting?
ok I'll try to, did you get the errors in the startup script? I'm currently in a car travelling from Sydney to Quensland (Australia) so when I get to the place I'm stayin at I'll try to find the errors in the Api(NMF).

You should really use Pastebin to upload your scripts. No one is going to download it from Mediafire.
Ok I'll use pastebin instead.
ardera #9
Posted 14 December 2013 - 05:28 PM
Well the thing is, you're not doing anything.

you load the NMF API,
and call the function "start", which does
print some options on the screen.

that's all.

I think you wanted, that the user chooses an option now, but you're not doing it.

You're missing something like

print("Enter either login or admin login:")
local whichlogin = read()
if whichlogin == "login" then
  NMF.Login()
elseif whichlogin == "admin login" then
  NMF.Admin_Login()
end
in your NMF.start function.

Same inside your Admin_Login function:
you only define to functions there, you give your user no chance to choose what function he wants to choose.

Also, in your startup file, if the user doesn't enter start, he will get to the shell. you should add an else, which reboots the pc. You could make a while loop too - if you know how to.
Nom #10
Posted 15 December 2013 - 02:29 PM
Well the thing is, you're not doing anything.

you load the NMF API,
and call the function "start", which does
print some options on the screen.

that's all.

I think you wanted, that the user chooses an option now, but you're not doing it.

You're missing something like

print("Enter either login or admin login:")
local whichlogin = read()
if whichlogin == "login" then
  NMF.Login()
elseif whichlogin == "admin login" then
  NMF.Admin_Login()
end
in your NMF.start function.

Same inside your Admin_Login function:
you only define to functions there, you give your user no chance to choose what function he wants to choose.

Also, in your startup file, if the user doesn't enter start, he will get to the shell. you should add an else, which reboots the pc. You could make a while loop too - if you know how to.
i don't get it.
Bomb Bloke #11
Posted 15 December 2013 - 06:45 PM
You should really use Pastebin to upload your scripts.