Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal

reteyez

Members
  • Content Count

    5
  • Joined

  • Last visited

Posts posted by reteyez

  1. 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.

  2. 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.

  3. 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.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.