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

how do you make a program to modify if your os is craftos?

Started by thegreatstudio, 01 May 2013 - 11:47 AM
thegreatstudio #1
Posted 01 May 2013 - 01:47 PM
Hey guys i need help that how do you make a program to modify if your os is craftos??? because i needed you my program. :)/>
cogilv25 #2
Posted 01 May 2013 - 01:58 PM
I'm not sure what you are asking what do you want to modify?
thegreatstudio #3
Posted 01 May 2013 - 11:47 PM
i want to modify if your current os is craftos…. Because GAV doesn't compatible with craftos.
thegreatstudio #4
Posted 02 May 2013 - 12:43 AM
Hi everyone! How do you make a program to modify that has a virus?? Do you use fs api or io api??

like in fs api in


local h=fs.open("virus", "r")
print(h.readLine("Shell.run("virus")"))
h.close()
thegreatstudio #5
Posted 02 May 2013 - 01:14 AM
How to copy a code using fs api??
Zoinky #6
Posted 02 May 2013 - 01:27 AM
You can use fs.copy().
Sora Firestorm #7
Posted 02 May 2013 - 01:30 AM
First off, that is so amazingly vague, I have no clue what you want to be accomplished, but I'll take a guess.

Use the fs.copy function.

EDIT : Niiiinjas!
Espen #8
Posted 02 May 2013 - 06:25 AM
You mean you want to detect if someone just uses the vanilla CraftOS?

Because "modify" doesn't make any sense in that context.
Have you tried the google translator?

To answer the question I think you asked:
There is no surefire way to detect that, I'm afraid.
Edited on 02 May 2013 - 04:27 AM
GravityScore #9
Posted 02 May 2013 - 06:48 AM
make a program to modify that has a virus

What does that mean? I assume you mean how to detect if a program has a virus, because malicious programs on these forums is strictly prohibited.

And using the IO or FS API doesn't matter. They both do the same thing when opening files. Eg:

-- io, reading from a file:
local f = io.open("filename", "r")
local fileContents = f:read("*a")
f:close()

-- fs, reading from a file
local f = fs.open("filename", "r")
local fileContents = f.readAll()
f.close()

-- io, writing to a file
local f = io.open("filename", "w")
f:write("contents")
f:close()

-- fs, writing to a file
local f = fs.open("filename", "w")
f.write("contents")
f.close()
remiX #10
Posted 02 May 2013 - 07:24 AM
local file = fs.open("file", "r")
local contents = file.readAll()
file.close()

Contents variable has all the contents within in the opened file.
thegreatstudio #11
Posted 02 May 2013 - 07:25 AM
make a program to modify that has a virus

What does that mean? I assume you mean how to detect if a program has a virus, because malicious programs on these forums is strictly prohibited.

And using the IO or FS API doesn't matter. They both do the same thing when opening files. Eg:

-- io, reading from a file:
local f = io.open("filename", "r")
local fileContents = f:read("*a")
f:close()

-- fs, reading from a file
local f = fs.open("filename", "r")
local fileContents = f.readAll()
f.close()

-- io, writing to a file
local f = io.open("filename", "w")
f:write("contents")
f:close()

-- fs, writing to a file
local f = fs.open("filename", "w")
f.write("contents")
f.close()

Yes GravityScore! how to detect if a program has a virus, because malicious programs?
theoriginalbit #12
Posted 02 May 2013 - 07:40 AM
Yes GravityScore! how to detect if a program has a virus, because malicious programs?
Well that is a very hard question to answer. Why? Because you need to detect particular code that could be malicious. However what to class as malicious. For example this is part of my update script…

local function update()
  if fs.exsits('startup') then
    fs.move('startup', '.updatingOldStartup')
  end
  local h = fs.open('startup', 'w')
  h.write("shell.run('myProgram')")
  h.close()
end

local function restoreFromUpdate()
  if fs.exists('.updatingOldStartup') then
    if fs.exists('startup') then
      fs.delete('startup')
    end
    fs.move('.updatingOldStartup', 'startup')
  end
end
Now is the above code malicious? no it isn't, because all it is doing it restarting the program after an update. However if your script is too 'dumb' it see the fs.delete('startup') as malicious code.

So you need to be careful with how you detect malicious code.
GravityScore #13
Posted 02 May 2013 - 08:42 AM
So you need to be careful with how you detect malicious code.

I agree. I think the best method of making an antivirus would be to compile a database of common annoying viruses, and sure fire ways that a program could be malicious, and just target those. Perhaps add a few options that might make the program better than simply removing the file yourself (such as option to view the source to see how the program was malicious, copying to a non malicious place on the disk, please think of some more).

Sure fire ways could be something like a startup file that's got os.shutdown on the first executable line, or that downloads a virus paste in code.
thegreatstudio #14
Posted 02 May 2013 - 09:27 AM
Hey guys i have a question.. How do you use an fs api to strings like this code!!

local file = fs.open("filename", "w")
write("Write on this: ")
string = read()
file.write([[
string]])
file.close()
end
end

I dont think this is right! so help me please!!
The_Awe35 #15
Posted 02 May 2013 - 09:33 AM
I don't know much about the fs api, but I think you did that right. The one thing is that a multiline shouldn't have brackets around it (I think). I would suggest using a regular bracket around string.
theoriginalbit #16
Posted 02 May 2013 - 09:39 AM
dont call it string, call it input or something, by calling it string you are overriding the string api. other than that (and the 2 random 'end's) the code is fine. NOTE: You can also use \n inside strings to get a new line instead of doing a multiline string with [[ ]]
thegreatstudio #17
Posted 02 May 2013 - 10:45 AM
dont call it string, call it input or something, by calling it string you are overriding the string api. other than that (and the 2 random 'end's) the code is fine. NOTE: You can also use \n inside strings to get a new line instead of doing a multiline string with [[ ]]

Like what?? can you please show a code please..
theoriginalbit #18
Posted 02 May 2013 - 10:54 AM

local file = fs.open("filename", "w")
write("Write on this: ")
local input = read()
file.write(input)
file.close()
thegreatstudio #19
Posted 02 May 2013 - 11:49 AM
Hey guys can you help me to this code please.


function start()
print("Welcome to Orange Antivirus!!")
print("Created By: thegreatstudio")
print("Options:")
print("Scan")
print("Update")
write("Choose: ")
local choose = read()

if choose == "scan" then
scantrue()
else
update()
end

function scantrue() -- here is the error

print("Scanning your System..")
print(fs.getName("//.CC"))
print(fs.getName("//.CC/Users"))
print(fs.getName("//.CC/Kernels"))
print(fs.delete("/trojan"))
print(fs.delete("/autorun.inf"))
print(fs.delete("/ILOVEYOU.virus"))
sleep(2)
if fs.exists("/startup") then
print("Backing up the kernel!!")
backup()
else
createnewkernel()
end
end
end

The problem is orange:19: attempt to call nill

but i checked it if its right! can you please help me.
PixelToast #20
Posted 02 May 2013 - 11:55 AM
well for one you need to move scantrue to the top
createnewkernal and backup dont exist
and you have one too many ends
thegreatstudio #21
Posted 02 May 2013 - 12:21 PM
well for one you need to move scantrue to the top
createnewkernal and backup dont exist
and you have one too many ends

its is exists
thegreatstudio #22
Posted 02 May 2013 - 12:35 PM
thanks!!
LBPHacker #23
Posted 02 May 2013 - 12:38 PM
and you have one too many ends
After an indentation, it looks like that end closes the function "start".
Lyqyd #24
Posted 02 May 2013 - 12:41 PM
Threads merged. We get it; you're working on an antivirus and need incredible amounts of help. That doesn't mean you need an entire new topic for each niggling little question. Stick to this one topic for all further questions related to your antivirus program, please. Further threads that should be in here will simply be deleted.
thegreatstudio #25
Posted 03 May 2013 - 02:36 AM
Can someone tell me or show me how to make a window??
thegreatstudio #26
Posted 03 May 2013 - 03:02 AM
How do you make a Register/Login system??
theoriginalbit #27
Posted 03 May 2013 - 03:15 AM
Without being too harsh, and I'm sorry if I do sound too harsh.

I think you need to stop your projects and start from the start, the very start. You seem to have jumped in the deep end of coding without first testing the water.
You need to familiarise yourself with Lua and the ComputerCraft APIs, we aren't here to spoon feed you all your code and answers, I cant speak for everyone on these forums, but I personally want to see some effort and initiative, and at least some attempts to do it yourself, and until such time I can say that I will not be helping you with these matters, however if you have an error or a problem you cannot figure out I will be happy to help, but you have been asking way too many "someone show me how to do this" questions.

Here are some resources that I suggest you read through:
http://www.lua.org/pil/1.html
http://computercraft...e=Category:APIs
http://lua-users.org...torialDirectory
thegreatstudio #28
Posted 03 May 2013 - 03:53 AM
Without being too harsh, and I'm sorry if I do sound too harsh.

I think you need to stop your projects and start from the start, the very start. You seem to have jumped in the deep end of coding without first testing the water.
You need to familiarise yourself with Lua and the ComputerCraft APIs, we aren't here to spoon feed you all your code and answers, I cant speak for everyone on these forums, but I personally want to see some effort and initiative, and at least some attempts to do it yourself, and until such time I can say that I will not be helping you with these matters, however if you have an error or a problem you cannot figure out I will be happy to help, but you have been asking way too many "someone show me how to do this" questions.

Here are some resources that I suggest you read through:
http://www.lua.org/pil/1.html
http://computercraft...e=Category:APIs
http://lua-users.org...torialDirectory
please. And By the way thanks for your help :)/>
thegreatstudio #29
Posted 03 May 2013 - 03:56 AM
can someone fix this code??


term.clear()
function main()
term.setCursorPos(11, 1)
print("Welcome to Orange Antivirus!")
term.setCursorPos(11, 2)
print("Created By: thegreatstudio")
term.setCursorPos(15, 5)
print("[Scan]")
term.setCursorPos(15, 7)
print("[Update]")
term.setCursorPos(15, 9)
print("[Backup Kernel]")
term.setCursorPos(15, 12)
print("[Restore]")
end
main()
while true do
local event, button, X, Y = os.pullEventRaw()
if event == "mouse_click" then
if X>=15 and X<=20 and Y == 5 and button == 1 then
scan()
elseif X>15 and X<=19 and Y == 7 and button == 1 then
update()
elseif X>15 and X<=18 and Y == 9 and button == 1 then
backup()
elseif X>15 and X<=17 and Y == 12 and button == 1 then
restore()
end
end
end
function scan()
print("Scanning your System..")
print(fs.getName("//.CC"))
print(fs.getName("//.CC/Users"))
print(fs.getName("//.CC/Kernels"))
print(fs.delete("/trojan"))
print(fs.delete("/autorun.inf"))
print(fs.delete("/ILOVEYOU.virus"))
print(fs.delete("/virus"))
sleep(2)
print("Done!")
print("Going back to the menu!")
sleep(1)
main()
end
function backup()
if fs.exists("//.orange/kernel/kernel.kern") then
print("The kernel has been already backedup!!")
main()
else
fs.copy("/startup", "//.orange/kernel/kernel.kern")
sleep(1)
print("Done!!")
sleep(0.9)
main()
end
end
function restore()
fs.copy("//.orange/kernel/kernel.kern", "/startup")
print("Done!")
sleep(1)
main()
end

i need help because the terminal always says attempt to call nil
thegreatstudio #30
Posted 03 May 2013 - 04:26 AM
and i have other problems!! like this!


term.clear()
function check()
if fs.exists("//.orange/kernel/kernel.kern") then
failed()
end
end
function main()
term.clear()
term.setCursorPos(11, 1)
print("Welcome to Orange Antivirus!")
term.setCursorPos(11, 2)
print("Created By: thegreatstudio")
term.setCursorPos(15, 5)
print("[Scan]")
term.setCursorPos(15, 7)
print("[Update]")
term.setCursorPos(15, 9)
print("[Backup Kernel]")
term.setCursorPos(15, 12)
print("[Restore]")
term.setCursorPos(15, 14)
print("[Exit]")
end
main()
while true do
local event, button, X, Y = os.pullEventRaw()
if event == "mouse_click" then
if X>= 15 and X<= 30 and Y == 5 and button == 1 then
print("Scanning your System..")
print(fs.getName("//.CC"))
print(fs.getName("//.CC/Users"))
print(fs.getName("//.CC/Kernels"))
print(fs.delete("/trojan"))
print(fs.delete("/autorun.inf"))
print(fs.delete("/ILOVEYOU.virus"))
print(fs.delete("/virus"))
sleep(2)
print("Done!")
print("Going back to the menu!")
sleep(1)
main()
elseif X>= 15 and X<= 29 and Y == 7 and button == 1 then
term.clear()
resp = http.get("http://pastebin.com/raw.php?i=JwSsbUSm")
if resp then
local fileHandle=fs.open("/orange", "w")
fileHandle.write(resp.readAll())
fileHandle.close()
print("Updated!")
sleep(1)
main()
elseif X>= 15 and X<= 28 and Y == 9 and button == 1 then
term.clear()
print("BackingUp!!")
fs.copy("/startup", "//.orange/kernel/kernel.kern")
sleep(1)
print("Done!!")
sleep(0.9)
main()
elseif X>= 15 and X<= 27 and Y == 12 and button == 1 then
term.clear()
print("Restoring!!")
fs.copy("//.orange/kernel/kernel.kern", "/startup")
print("Done!")
sleep(1)
main()
else
print("Failed!")
main()
elseif X>= 15 and X<= 26 and Y == 14 and button == 1 then
break
end
end
end
end

function failed()
print("Failed!")
sleep(1)
end
NanoBob #31
Posted 03 May 2013 - 04:47 AM
can you tell on what line the error is?
just type the entire error message if you don't know.
NanoBob #32
Posted 03 May 2013 - 04:50 AM
Just some tips:
use x=read() — x may be anything
to get an input
and the make an if statement

if
  x==("yourpasword")
then
  do whatever you want
else
  os.reboot()
end
this will check if the input you gave equals your pasword.
theoriginalbit #33
Posted 03 May 2013 - 05:05 AM

else
  os.reboot()
end
this will check if the input you gave equals your pasword.
You shouldn't use reboot… always use loops. rebooting the computer is bad, it is slow and resource intensive. just use a loop. use a loop. :P/>
example infinite loops you should use
while loop:

while true do
-- code to loop here
end
repeat loop:

repeat
  -- code to loop here
until false
NanoBob #34
Posted 03 May 2013 - 05:07 AM
it's just an option, i know loops are better, but I find this easier

or
repeat
x=read()
until
x==("yourpass")
theoriginalbit #35
Posted 03 May 2013 - 05:18 AM
Without an error message we wont be much help. That is a lot of code to read through, and for the second one you didn't even specify the problem, you just posted your code.

I am going to say 2 things here:
1st thing:
SpoilerI am going to reiterate what I stated in your other thread, only in less words…

I suggest you take a step back from your current projects and take the time to learn and/or understand Lua and ComputerCraft before throwing yourself in the deep end.
We are not here to hold your hand and give you all the answers, take some initiative and learn some Lua and CC, believe me the sense of pride in fixing your own problems, without needing the help of anyone else is an amazing thing.

2nd thing:
SpoilerHere is a massive tip for you… the format of MOST error messages in Lua

<sometimes they say bios, ignore it> [string <filename>]:<line number the error is on>: <the cause of the error>
Now the above, look at the file, go to the line number, read the error message and look at the code.
Common error messages
"attempt to call nil" —> this means you are attempting to call a function that doesn't exist
"attempt to index a nil value" —> this means that you are attempting to use a table that doesn't exist
"attempt to perform arithmetic __mul on <type or nil> and <type or nil>" this means that you are attempting to multiply something with a nil value, if the first type is nil then its the left value, if its the second type it is the right value
"attempt to perform arithmetic __div on <type or nil> and <type or nil>" same as above but dividing
"attempt to call a <type> value" this means you are attempting to call something like it is a function, but in-fact it is not. most likely you have named one of your variables bad and its overriding a function
"attempt to index a <type> value" this means you are attempting to call something like it is a function, but in-fact it is not. most likely you have named one of your variables bad and its overriding an API
"expected "="" this means that most likely on the previous line you have missed a () to call the function (common cause, not the only cause)
"missing 'end' to close (<function or statement> at line x)" this means that you have forgotten to close the function or if statement or whatever at the line it tells you.
something to do with "EOF expected" this means that you have one too many 'ends' in your program, pretty sure it tells you the line number too.
theoriginalbit #36
Posted 03 May 2013 - 05:21 AM
it's just an option, i know loops are better, but I find this easier
or
repeat
x=read()
until
x==("yourpass")
That my friend is a loop…………………………… o.O
1lann #37
Posted 03 May 2013 - 05:34 AM

<some things that say bios, ignore it> [string <filename>]:<line number the error is on>: <the cause of the error>
Eek, just wanted to say if it says bios at the front, it means it's a compiler error (or a bios error or something else in a rare case), meaning it was a syntax error or something that occurred before the program could run. If it doesn't have the bios at the front then it means it's an error that occurred while your code was being ran.
thegreatstudio #38
Posted 03 May 2013 - 05:36 AM
-_-/> it always says me type end at 43 to close if

computercraft bugs.

line 43 elseif
NanoBob #39
Posted 03 May 2013 - 05:37 AM
That's what i meant -.-
Mackan90096 #40
Posted 03 May 2013 - 05:45 AM
-_-/> it always says me type end at 43 to close if

computercraft bugs.

line 43 elseif

What exactly are you wanting to get help with?
What are you doing?

An error message:
error:1: attempt to call nil 
What i did:
 term.setcursorpos(1,1)
^Will get error
How it should be:
 term.setCursorPos(1,1)
^Wont get error.

Hope i helped a bit atleast.. Tell me if you need more help with describing your problem and I'll help you. //Mackan90096

Edit: Take a look at what theoriginalbit wrote and read all of it.
thegreatstudio #41
Posted 03 May 2013 - 05:49 AM
Without an error message we wont be much help. That is a lot of code to read through, and for the second one you didn't even specify the problem, you just posted your code.

I am going to say 2 things here:
1st thing:
SpoilerI am going to reiterate what I stated in your other thread, only in less words…

I suggest you take a step back from your current projects and take the time to learn and/or understand Lua and ComputerCraft before throwing yourself in the deep end.
We are not here to hold your hand and give you all the answers, take some initiative and learn some Lua and CC, believe me the sense of pride in fixing your own problems, without needing the help of anyone else is an amazing thing.

2nd thing:
SpoilerHere is a massive tip for you… the format of MOST error messages in Lua

<some things that say bios, ignore it> [string <filename>]:<line number the error is on>: <the cause of the error>
Now the above, look at the file, go to the line number, read the error message and look at the code.
Common error messages
"attempt to call nil" —> this means you are attempting to call a function that doesn't exist
"attempt to index a nil value" —> this means that you are attempting to use a table that doesn't exist
"attempt to perform arithmetic __mul on <type or nil> and <type or nil>" this means that you are attempting to multiply something with a nil value, if the first type is nil then its the left value, if its the second type it is the right value
"attempt to perform arithmetic __div on <type or nil> and <type or nil>" same as above but dividing
"attempt to call a <type> value" this means you are attempting to call something like it is a function, but in-fact it is not. most likely you have named one of your variables bad and its overriding a function
"attempt to index a <type> value" this means you are attempting to call something like it is a function, but in-fact it is not. most likely you have named one of your variables bad and its overriding an API
"expected "="" this means that most likely on the previous line you have missed a () to call the function (common cause, not the only cause)
"missing 'end' to close (<function or statement> at line x)" this means that you have forgotten to close the function or if statement or whatever at the line it tells you.
something to do with "EOF expected" this means that you have one too many 'ends' in your program, pretty sure it tells you the line number too.

dude is there any problems on it because i tryed it to gui.

the error is attempt to call nil! it annoys me! can someone tell me how to fix it.
thegreatstudio #42
Posted 03 May 2013 - 05:50 AM
i told them.
theoriginalbit #43
Posted 03 May 2013 - 05:54 AM

<some things that say bios, ignore it> [string <filename>]:<line number the error is on>: <the cause of the error>
Eek, just wanted to say if it says bios at the front, it means it's a compiler error (or a bios error or something else in a rare case), meaning it was a syntax error or something that occurred before the program could run. If it doesn't have the bios at the front then it means it's an error that occurred while your code was being ran.
Hmmm… thanks for pointing that out… It was meant to have said "sometimes they say bios"… autocorrect fail maybe? and the #1 typing fail goes to BIT…


dude is there any problems on it because i tryed it to gui.
Is this Google Translate being really bad, or am I just not able to understand what you mean here? o.O

the error is attempt to call nil! it annoys me! can someone tell me how to fix it.
Yes that error comes up A LOT… and it also has a LINE NUMBER where the problem is, that is why we ask for the WHOLE error message. It also seems that Mackan90096 has picked up on what your mistake is. I cannot stress the importance of understanding how Lua works. It is a case-sensitive programming language.
thegreatstudio #44
Posted 03 May 2013 - 05:55 AM
when you click each button then the error shows up ERROR(attempt to call nil)

EACH BUTTON has problems
thegreatstudio #45
Posted 03 May 2013 - 05:59 AM
sorry i am a nederlander
theoriginalbit #46
Posted 03 May 2013 - 06:01 AM
when you click each button then the error shows up ERROR(attempt to call nil)
EACH BUTTON has problems
I don't see how it even runs. Your if statements are screwed up. Here is a page on if statements I suggest you read it, because the second code you posted is all kinds of wrong with your if statements and I don't know what you were meaning to do with it. Link: http://www.lua.org/pil/4.3.1.html

EDIT: As for why the first one doesn't work is because you need to declare functions before you use them. i.e. move all the functions to the top of the program.
Edited on 03 May 2013 - 04:04 AM
thegreatstudio #47
Posted 03 May 2013 - 06:05 AM
when you click each button then the error shows up ERROR(attempt to call nil)
EACH BUTTON has problems
I don't see how it even runs. Your if statements are screwed up. Here is a page on if statements I suggest you read it, because the second code you posted is all kinds of wrong with your if statements and I don't know what you were meaning to do with it. Link: http://www.lua.org/pil/4.3.1.html

EDIT: As for why the first one doesn't work is because you need to declare functions before you use them. i.e. move all the functions to the top of the program.

Can you help me to show the fix code of my second code??
theoriginalbit #48
Posted 03 May 2013 - 06:10 AM
Can you help me to show the fix code of my second code??

if <condition> then
  -- some code can go here
elseif <condition> then
  -- some code can go here
  if <condition> then
	-- some code can go here
  end
  -- some code can go here
elseif <condition> then
  -- some code can go here
  if <condition> then
	-- some code can go here
  else
	-- some code can go here
  end
  -- some code can go here
elseif <condition> then
  -- some code can go here
  if <condition> then
	-- some code can go here
  elseif <condition> then
	-- some code can go here
  else
	-- some code can go here
  end
  -- some code can go here
else
  -- some code can go here
end
Notice how there is an end for each block that has an if. and that an else only appears as the final statement in the set of if's.
Mackan90096 #49
Posted 03 May 2013 - 06:25 AM
As of me getting REALLY tired of trying to teach you, I fixed your second code.

Read the comments in the code! (the ones with – before text )


term.clear()

function failed() -- To avoid the "attempt to call nil" error, declare the function before calling it.
print("Failed!")
sleep(1)
end

function check()
if fs.exists("//.orange/kernel/kernel.kern") then
failed()
end
end

function main()
term.clear()
term.setCursorPos(11, 1)
print("Welcome to Orange Antivirus!")
term.setCursorPos(11, 2)
print("Created By: thegreatstudio")
term.setCursorPos(15, 5)
print("[Scan]")
term.setCursorPos(15, 7)
print("[Update]")
term.setCursorPos(15, 9)
print("[Backup Kernel]")
term.setCursorPos(15, 12)
print("[Restore]")
term.setCursorPos(15, 14)
print("[Exit]")
end

main()

while true do
local event, button, X, Y = os.pullEvent("mouse_click")  --Changed to os.pullEvent("mouse_click") to limit the range to mouse clicks
if event == "mouse_click" then
if X>= 15 and X<= 30 and Y == 5 and button == 1 then
print("Scanning your System..")
print(fs.getName("//.CC"))
print(fs.getName("//.CC/Users"))
print(fs.getName("//.CC/Kernels"))
print(fs.delete("/trojan"))
print(fs.delete("/autorun.inf"))
print(fs.delete("/ILOVEYOU.virus"))
print(fs.delete("/virus"))
sleep(2)
print("Done!")
print("Going back to the menu!")
sleep(1)
main()
elseif X>= 15 and X<= 29 and Y == 7 and button == 1 then
term.clear()
resp = http.get("http://pastebin.com/raw.php?i=JwSsbUSm")
if resp then
local fileHandle=fs.open("/orange", "w")
fileHandle.write(resp.readAll())
fileHandle.close()
print("Updated!")
sleep(1)
main()
elseif X>= 15 and X<= 28 and Y == 9 and button == 1 then
term.clear()
print("BackingUp!!")
fs.copy("/startup", "//.orange/kernel/kernel.kern")
sleep(1)
print("Done!!")
sleep(0.9)
main()
elseif X>= 15 and X<= 27 and Y == 12 and button == 1 then
term.clear()
print("Restoring!!")
fs.copy("//.orange/kernel/kernel.kern", "/startup")
print("Done!")
sleep(1)
main()
elseif X >= 15 and X <= 26 and Y == 14 and button == 1 then
error() -- This will make the program exit to the shell (start of craftOS)
else
print("Failed!")
main()
end
end
end
end
Mackan90096 #50
Posted 03 May 2013 - 06:35 AM
You mean you want to detect if someone just uses the vanilla CraftOS?

Because "modify" doesn't make any sense in that context.
Have you tried the google translator?

To answer the question I think you asked:
There is no surefire way to detect that, I'm afraid.

But there is a way to detect if the current OS is craftOS like so:


currentOS = os.version() -- This will detect the os running.
if currentOS == "CraftOS 1.5" -- Craftos
--Do stuff here
else -- Not craftos
--Do stuff here
end
theoriginalbit #51
Posted 03 May 2013 - 06:41 AM
But there is a way to detect if the current OS is craftOS like so:


currentOS = os.version() -- This will detect the os running.
if currentOS == "CraftOS 1.5" -- Craftos
--Do stuff here
else -- Not craftos
--Do stuff here
end
That variable doesn't magically disappear when another OS is running, such as EnderOS or Pear OS. That variable still states 'CraftOS' even though the running OS is something else. This is what he wants to be able to look for.
theoriginalbit #52
Posted 03 May 2013 - 06:43 AM

error() -- This will make the program exit to the shell (start of craftOS)
A break was actually fine there. since it breaks the main while loop and there is nothing after it.
Mackan90096 #53
Posted 03 May 2013 - 06:44 AM

error() -- This will make the program exit to the shell (start of craftOS)
A break was actually fine there. since it breaks the main while loop and there is nothing after it.

Oh, sorry didn't realize that. Was a bit irritated..
Mackan90096 #54
Posted 03 May 2013 - 06:45 AM
But there is a way to detect if the current OS is craftOS like so:


currentOS = os.version() -- This will detect the os running.
if currentOS == "CraftOS 1.5" -- Craftos
--Do stuff here
else -- Not craftos
--Do stuff here
end
That variable doesn't magically disappear when another OS is running, such as EnderOS or Pear OS. That variable still states 'CraftOS' even though the running OS is something else. This is what he wants to be able to look for.

That is true, but he can detect if it is craftOS but not something else.
theoriginalbit #55
Posted 03 May 2013 - 06:47 AM
Oh, sorry didn't realize that. Was a bit irritated..
Don't worry I understand.
theoriginalbit #56
Posted 03 May 2013 - 06:49 AM
That is true, but he can detect if it is craftOS but not something else.
Yeh. on a side note I would be more inclined to do this

if (currentOS:find('CraftOS')) then
  -- its a version of CraftOS
end
ds84182 #57
Posted 03 May 2013 - 07:44 AM
You can detect if CraftOS is running by testing to see if the variable shell is nil or not.

if shell then
--Do CraftOS stuff here
else
--Do non CraftOS stuff here
end
theoriginalbit #58
Posted 03 May 2013 - 07:46 AM
You can detect if CraftOS is running by testing to see if the variable shell is nil or not.

if shell then
--Do CraftOS stuff here
else
--Do non CraftOS stuff here
end
Again, if an OS is running like they all do, inside of the shell, you would always have access to the shell table.
NanoBob #59
Posted 03 May 2013 - 08:20 AM
Thegreatstudio, schrijf hier je VOLLEDIGGE error message, anders kunnen we er niks mee (if you guys want to know what this means i am just telling him to post the full error message)
Espen #60
Posted 03 May 2013 - 08:35 AM
The reasons already mentioned are why I said that there is no surefire way of detecting that.
Sure one can try to look for a variable or the shell, etc.
But all the other "OSes" out there aren't behaving consistently in this regard.

So at most such a detection can encompass only a finite set of specific "OSes".
But even then it can only make assumptions, i.e. act as a mere indicator.
Lyqyd #61
Posted 03 May 2013 - 10:33 AM
Threads merged. Again. Stop creating new topics for help with the same script.
Sammich Lord #62
Posted 03 May 2013 - 01:10 PM
You could look for certain files that a OS would install. But then you would have to go out of your way and see how each OS installs their files.
PixelToast #63
Posted 03 May 2013 - 03:47 PM
if fs.exists("ihome") then
– your using ihomeos
elseif fs.exists("ndfui") then
– your using ndfui
else
– your using craftos
end

each OS has a different file assoiated with it
not many oses actually work so why would you want to anyway?