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

[Question]How do you run code without saving it to a file?

Started by Mailmanq!, 03 March 2013 - 03:52 PM
Mailmanq! #1
Posted 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.
TwelveEight #2
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! :)/>
GopherAtl #3
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()
Shnupbups #4
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…
oeed #5
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.
Mailmanq! #6
Posted 04 March 2013 - 04:22 AM
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()
Exactly what I needed!
SuicidalSTDz #7
Posted 04 March 2013 - 02:07 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! :)/>
Not so much a "program". It just uses the built-in Lua interpreter to my understanding :P/>
theoriginalbit #8
Posted 04 March 2013 - 02:12 PM
Not so much a "program". It just uses the built-in Lua interpreter to my understanding :P/>
It is indeed a program. All it does is it uses environments and loadstring to complete its simple task…
SuicidalSTDz #9
Posted 04 March 2013 - 02:51 PM
Not so much a "program". It just uses the built-in Lua interpreter to my understanding :P/>
It is indeed a program. All it does is it uses environments and loadstring to complete its simple task…
But does it not use the interpreter in some way? Guess I just don't see it as a real program.
immibis #10
Posted 04 March 2013 - 04:05 PM
It's a real program just like copy is a real program.
SuicidalSTDz #11
Posted 04 March 2013 - 04:22 PM
It's a real program just like copy is a real program.
So, let's get things straight… "Lua" is a program which uses loadStrings and environments which "tap" into the built-in Lua interpreter, correct?
immibis #12
Posted 04 March 2013 - 05:18 PM
Yes. In the same way copy uses fs.copy to "tap" into the filesystem.
TwelveEight #13
Posted 06 March 2013 - 09:03 PM
Yes. In the same way copy uses fs.copy to "tap" into the filesystem.
Yay I'm not stupid! ^-^