While I'm writing a code...
The case I have to access 2 .lua files..
1. db_map.lua (Contain the Map data in Lua table format)
2. f_path.lua (Contain the function code for path function)
normally when I write a code, I will start with require
function path_gen(a,b)
require("db_map")
local x = a
local y = b
local x1 = string.gsub(x,"%d+","")
local y1 = string.gsub(y,"%d+","")
local p_back = Map[x1][x].Back
local p_a1 = Map[x1][x].Path
local p_a2 = Map[y1][y].Path
local p_go = Map[y1][y].Go
print(p_back)
print(p_a1)
print(p_a2)
print(p_go)
end
This works...but what if I want to add other function into this code , the code was store inside the "f_path.lua"
When I add
function path_gen(a,b)
require("db_map")
require("f_path")
local x = a
local y = b
local x1 = string.gsub(x,"%d+","")
local y1 = string.gsub(y,"%d+","")
.......
............
local z = path_mix(x,y)
The function "path_mix" was store inside f_path, when I run this code, it occur error said f_path.lua not found...
so strange, cannot run 2 x lua file at the same time?
how it solve or write code in otherway? Thanks. |