[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  Lua
. . -> [Subject]  require ("xxx") problem

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: require ("xxx") problem
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please)
Maximum of 6000 characters. Text only please, no HTML.
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Posted by Tkl1129   Hong Kong  (43 posts)  [Biography] bio
Date Wed 11 Jan 2012 02:00 AM (UTC)  quote  ]
Message
so strange,
maybe I try to do more testing first.

By the way, do all functions keep in *.lua good?
or maybe use "module" function is more easy to manage?

just want to share and learn you guys's preference..thanks.
[Go to top] top

Posted by Fiendish   USA  (848 posts)  [Biography] bio   Global Moderator
Date Wed 11 Jan 2012 01:53 AM (UTC)  quote  ]
Message
I do multiple requires all the time. Does one of your required files change the working directory?

http://aardwolfclientpackage.googlecode.com/
[Go to top] top

Posted by Tkl1129   Hong Kong  (43 posts)  [Biography] bio
Date Wed 11 Jan 2012 01:05 AM (UTC)  quote  ]
Message
inside the lua folder

when I run "db_map"...inside are Lua table data...
it's work

or I seperate run the "f_path"...inside are functions...
it's work too

but when I run


require("db_map")
require("f_path")


the code when run the function which inside "f_path", it return "nil"....

so wanna ask is that not appropriate to run 2 lua together? or have another method like "module"
[Go to top] top

Posted by Nick Gammon   Australia  (18,770 posts)  [Biography] bio   Forum Administrator
Date Tue 10 Jan 2012 07:21 PM (UTC)  quote  ]
Message
Where are these two .lua files stored? In the same place as each other? What is that place?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Tkl1129   Hong Kong  (43 posts)  [Biography] bio
Date Tue 10 Jan 2012 07:13 AM (UTC)  quote  ]
Message
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.
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


1,342 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]