View unanswered posts | View active topics It is currently Sun Oct 21, 2018 3:00 am



Reply to topic  [ 4 posts ] 
 Requiring lua files 
Author Message
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Requiring lua files
So I have this base script that has a couple of functions that multiple other scripts will use, and for the sake of good programming practices I want the other scripts to do a require of that file, however I'm getting errors when I do it.

All the scripts are in Mod.rte/Scripts, but when I try to do require("Mod.rte/Scripts/FileWithFunctions.lua") I get a lengthy "module not found" error with all the places it searched for it, which includes Mod.rte/Scripts/FileWithFunctions.lua.

I also tried with what I found here, but I still can't get it to work.

Any help?


Mon Dec 18, 2017 8:44 pm
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 657
Location: Halifax, Canada
Reply with quote
Post Re: Requiring lua files
You need to use dofile - dofile("Mod.rte/path_to_script"). I think require only accepts things in base or something, so maybe you could do require("../Mod.rte/path_to_script")? I don't quite remember now how it works differently to be honest.


Wed Dec 20, 2017 11:58 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Requiring lua files
Using dofile instead of required did it! I've sure learnt a lot of lua now lol, thanks a lot for the help again! :D


Wed Dec 20, 2017 8:33 pm
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 657
Location: Halifax, Canada
Reply with quote
Post Re: Requiring lua files
Cheers man, keep at it and keep learning!


Thu Dec 21, 2017 1:46 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.016s | 15 Queries | GZIP : Off ]