- Sky
- Blueberry
- Slate
- Blackcurrant
- Watermelon
- Strawberry
- Orange
- Banana
- Apple
- Emerald
- Chocolate
- Charcoal
reteyez
-
Content Count
5 -
Joined
-
Last visited
Posts posted by reteyez
-
-
I tried os.execute before but I didn't got that argument right, Now I know, thanks.
Anyhow I went with dofile instead and it suits more my needs.
If you want to know why this whole trouble:
-
Thanks for the answer. Yea that would be a way to do it. I did it totally different by now though . I use dofile instead of shell.execute now and the object table is just a local table inside the Handler (which I access with Handler.functions) so it gets passed as upvalue to the file that I run with dofile. And thanks for the tip with the locals, I'll keep it in mind.
-
Is it possible to require a libary within a file which then executes another file and passes the required libary to it?
-
Im trying to create a utility "class" wich returns "allObjects" either by function or directly.
Objects are files within a specified folder with a specified extension.
local Handler = {object = {}} local workspace = { shell.getWorkingDirectory().."dir1", shell.getWorkingDirectory().."dir2" } for key, dir in pairs(workspace) do for element in fs.list(dir) do local s, e = string.find(element, "%.") local ext = string.sub(element, s + 1) local title = string.sub(element, 1, s - 1) if ext == "foo" or ext == "bar" then if Handler.object[ext] == nil then Handler.object[ext] = {} end result, Handler.object[ext][title] = shell.execute(dir.."/"..element) end end end return Handler
Works actually fine but the problem is that I need to require the handler in the object files themselfs since they need to know eachother.
This though leads to a problem since I also use the handler in the main class which when called gives the error:
"already loading: handler"
Example of an object ("dir1/obj1.foo"):
local handler = require("handler") local obj1 obj1.title = handler.object.foo.obj2.title return obj1
The main file needs the handler aswell:
local handler = require("handler") --For example for k, v in pairs(handler.object.foo) v.run() end
which isn't a suprise. I also tried shell.execute instead of require which ended in an endless loop. I understand the problem but I can't think of an elegant way to solve it.
How to handle long errors
in Programming
Posted
As the title says I'm curious how you guys handle errors that are to big for the screen so that the top part (the important one) gets cut out.
Is there any way to scroll up? It'd also be nice to create a log file after each crash with the error in it.