64 posts
Posted 04 January 2013 - 06:37 AM
Is There A Function Like Shell.run() for Normal Lua(without any cc apis)? I Am Using A iOS Application Titled: "Touch Lua" and i know how to do most things on it except making it do like a shell.run() type of function?
P.S. I Have No Way To Access lua.org
Regards'
Dusty_rebel
8543 posts
Posted 04 January 2013 - 06:42 AM
Try loadstring. Returns a function if the string loaded successfully, or (I believe) nil and an error message if it didn't.
64 posts
Posted 04 January 2013 - 06:53 AM
If I May Ask How Do I Loadstring? I really suck at (non-cc/roblox) Lua
64 posts
Posted 04 January 2013 - 06:56 AM
P.S. im using this for a quiz script i made on my phone so that if you get incorrect it restarts the program
1190 posts
Location
RHIT
Posted 04 January 2013 - 07:11 AM
local f = io.open("program", "r")
local content = f:read("*all")
f:close()
local runCode = loadstring(content)
runCode()
Although the above code should work, I don't really see a need to use loadstring in this case. Just encapsulate your quiz code in a function, and then use simple if/else statements to decide whether to restart or continue.
1688 posts
Location
'MURICA
Posted 04 January 2013 - 07:16 AM
Isn't there a loadfile() and dofile() in lua?
1190 posts
Location
RHIT
Posted 04 January 2013 - 07:20 AM
Isn't there a loadfile() and dofile() in lua?
Actually yes there is. It's usage is dofile([progname]). That would be a simpler way to go about it, but I still think that an entire program restart is unnecessary.
8543 posts
Posted 04 January 2013 - 07:33 AM
And probably fills the stack. This should be accomplished with the use of a (rather elementary) loop, nothing more.
64 posts
Posted 04 January 2013 - 07:55 AM
But i also want to be able to run a differnet program from one program for instance a main script that lets you say "quiz" and it bring you to the quiz
so can anyone help me with that?
64 posts
Posted 04 January 2013 - 07:57 AM
and when i do dofile("Quiz") it says ERROR: unknown directory/file
8543 posts
Posted 04 January 2013 - 08:42 AM
Then you obviously have the wrong path to the file. Try looking through the documentation to see what the path should look like.
64 posts
Posted 04 January 2013 - 08:44 AM
the documentation? im usin an iOS applictaion…
8543 posts
Posted 04 January 2013 - 08:51 AM
Yes, the documentation for whatever app you're using. The app, by the way, that none of us have any reason to have any experience with, or know anything about, and that isn't ComputerCraft. So don't expect us to be able to answer questions about it like we can about ComputerCraft.
799 posts
Location
Land of Meh
Posted 04 January 2013 - 08:55 AM
In ComputerCraft, whenever you specify a file path, it is taken from the root directory of the computer you're using. Since you're not using ComptuerCraft, the file path you'll have to specify is the full path to the file you want to run using dofile (or to open using the io API - the FS api doesn't exist outside of ComptuerCraft). Full paths are taken from the root of your computer, like so:
Windows (not sure about this full path):
C:\Users\yourusernamehere\My Documents\Lua\test.lua
Mac:
/Users/yourusernamehere/Documents/Lua/test.lua
or
~/Documents/Lua/test.lua
The error unknown file or directory means that Lua could not find the file - it doesn't exist. That's because you didn't specify the full path to it.
8543 posts
Posted 04 January 2013 - 08:59 AM
Though, you might try ./filename, since that can often be used for relative paths.
64 posts
Posted 04 January 2013 - 09:56 AM
Ok I'll try that
EDIT: /Quiz Still doesnt work :/
Edited on 04 January 2013 - 09:13 AM
64 posts
Posted 04 January 2013 - 10:18 AM
i checked the documentation it says nothing about path directories…
1054 posts
Posted 04 January 2013 - 10:22 AM
Ok I'll try that
EDIT: /Quiz Still doesnt work :/
Not /Quiz, ./Quiz . With a dot in front. Is the quiz file in the same directory as the main file?
64 posts
Posted 04 January 2013 - 10:28 AM
Oh ./Quiz ok and I don't know…
EDIT: nope still don't work :/
64 posts
Posted 04 January 2013 - 10:38 AM
I think I'm gonna use iExplorer…
EDIT: I tried documents/quiz and it just didn't work I saw that's where the directory is and it didn't work :/
64 posts
Posted 04 January 2013 - 10:49 AM
I way insert some cc Apis while im in iExplorer