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

LamboCreeper

Members
  • Content Count

    1
  • Joined

  • Last visited

Posts posted by LamboCreeper

  1. Hey,

    I haven't worked with Lua in a while and recently my friends and I started a new modded game. I'm currently trying to require another file from another, and to my knowledge have done it to how the syntax describes. However, OpenOS is giving me an error stating the following:

    tyGEc1Su.png

    However, when running the cd command it states that core.lua does indeed exist in the directory /home/

    VatJ1M-3.png

    This is my code:

    -- core.lua
    
    function catch(inp)
    	return inp[1]
    end
    
    function try(inp)
    	status, res = pcall(inp[1])
    	if not status then
    		inp[2](res)
    	end
    	return res
    end
    
    -- test.lua
    
    function dir()
       local str = debug.getinfo(2, "S").source:sub(2)
       return str:match("(.*/)")
    end
    
    -- this is where it breaks:
    require(dir() .. "core.lua")
    
    local http
    
    core.try {	
    	function()
    		http = require("socket.http")
    		local body, code = http.request('https://raw.githubusercontent.com/rxi/json.lua/master/json.lua')
    		local f = assert(io.open('modules/json.lua', 'wb'))
    		f:write(body)
    		f:close()
    		print('Successfully downloaded json.lua module.')
    	end, core.catch {
    		function(err)
    			print('Caught Error: ' .. err)
    		end
    	}
    }

    If someone could please explain to me what I am doing wrong and more specifically how to fix the issue it would be greatly appreciated.

×
×
  • Create New...

Important Information

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