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

Basic LUA questions for Computercraft

Started by Debugger, 29 May 2014 - 01:51 PM
Debugger #1
Posted 29 May 2014 - 03:51 PM
First, thank you for helping out. I'm at work daydreaming about being at home testing this out but figured I would get better info asking you guys directly. I know it's my own ignorance but this feels linear like QBasic (thumbs up), and not sure how OOP the default API can be.
  1. Can I execute a secondary script without interrupting the first script?
  2. Can I return data from the secondary script without interrupting the first script?
  3. Can I make my own Classes without having server side access?

Thanks again for the assistance.
Lyqyd #2
Posted 29 May 2014 - 06:12 PM
1. Sort of.
2. Sort of. Probably not how you're thinking, though.
3. What do you mean by "Classes"?
Lignum #3
Posted 29 May 2014 - 06:21 PM
3. What do you mean by "Classes"?
I believe he means classes from object-oriented programming. Yes, you can. It's not as convenient as in other languages but it works.
Debugger #4
Posted 29 May 2014 - 06:30 PM
Thanks for the reply Lyqyd.

Classes: like a permanent function/method on another script outside of the current scope of the script currently running. I suppose it could be fudged by having other terminals running individual scripts and grabbing variables from those when needed. I don't know though =x

3. What do you mean by "Classes"?
I believe he means classes from object-oriented programming. Yes, you can. It's not as convenient as in other languages but it works.
Perfect! I'll take a gander.
Bomb Bloke #5
Posted 30 May 2014 - 01:13 AM
It sounds like you may find this API tutorial to be worth a read.

If there's a specific block of code you intend to port or whatever, then you may be better off linking to (or at least describing) it here. We can't really comment on the best way to do something in Lua without knowing exactly what that something is.

Lua is indeed very similar to QB, but (at least in CC) you'll be relying a lot on events.