I know this isn't nessecary, but if I can it would be nice, in there happens to be a file already named that.
This is a read-only snapshot of the ComputerCraft forums,
taken in April 2020.
[Question]How do you run code without saving it to a file?
Started by Mailmanq!, 03 March 2013 - 03:52 PMPosted 03 March 2013 - 04:52 PM
The title asks it.
I know this isn't nessecary, but if I can it would be nice, in there happens to be a file already named that.
I know this isn't nessecary, but if I can it would be nice, in there happens to be a file already named that.
Posted 03 March 2013 - 04:59 PM
You can use the program "lua", which allows you to run lua code live. You can even use peripherals with it, do loops, etc.
I hope that I helped! :)/>
I hope that I helped! :)/>
Posted 03 March 2013 - 06:45 PM
Not clear what you're trying to do exactly, but loadstring() takes in a string containing lua code, compiles it and, if it was valid, returns a function that can be called, ex:
local code='print("hello!"')
local myFunc=loadstring(code)
myFunc()
Posted 03 March 2013 - 08:10 PM
I've been thinking of making a file editor for a while now which will have code testing without saving, but never really got around to it…
Posted 03 March 2013 - 08:26 PM
I've been thinking of making a file editor for a while now which will have code testing without saving, but never really got around to it…
One of the applications I intend to add to PearOS if I get the time is an 'IDE' (if you can call it that really) a bit like this.
Posted 04 March 2013 - 04:22 AM
Exactly what I needed!Not clear what you're trying to do exactly, but loadstring() takes in a string containing lua code, compiles it and, if it was valid, returns a function that can be called, ex:local code='print("hello!"') local myFunc=loadstring(code) myFunc()
Posted 04 March 2013 - 02:07 PM
Not so much a "program". It just uses the built-in Lua interpreter to my understanding :P/>You can use the program "lua", which allows you to run lua code live. You can even use peripherals with it, do loops, etc.
I hope that I helped! :)/>
Posted 04 March 2013 - 02:12 PM
It is indeed a program. All it does is it uses environments and loadstring to complete its simple task…Not so much a "program". It just uses the built-in Lua interpreter to my understanding :P/>
Posted 04 March 2013 - 02:51 PM
But does it not use the interpreter in some way? Guess I just don't see it as a real program.It is indeed a program. All it does is it uses environments and loadstring to complete its simple task…Not so much a "program". It just uses the built-in Lua interpreter to my understanding :P/>
Posted 04 March 2013 - 04:05 PM
It's a real program just like copy is a real program.
Posted 04 March 2013 - 04:22 PM
So, let's get things straight… "Lua" is a program which uses loadStrings and environments which "tap" into the built-in Lua interpreter, correct?It's a real program just like copy is a real program.
Posted 04 March 2013 - 05:18 PM
Yes. In the same way copy uses fs.copy to "tap" into the filesystem.
Posted 06 March 2013 - 09:03 PM
Yay I'm not stupid! ^-^Yes. In the same way copy uses fs.copy to "tap" into the filesystem.