Help with your scripting

require()

require()

Postby ant0N » 14 Mar 2015, 06:03

Hi! You cannot use this command.
I do so:
Code: Select all
require("script.lua")
require("..\Scripts\script.lua")


but it doesn't work.
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: require()

Postby Shando » 14 Mar 2015, 06:58

Hi ant0N,

Apparently, the "require" function uses the LUA_PATH global variable in Windows:

To determine its path, require first checks the global variable LUA_PATH. If the value of LUA_PATH is a string, that string is the path. Otherwise, require checks the environment variable LUA_PATH. Finally, if both checks fail, require uses a fixed path (typically "?;?.lua", although it is easy to change that when you compile Lua).


This is from http://www.lua.org/pil/8.1.html.

So, not sure how it would work inside Skyline :?

Regards

Shando
Ryzen 7 4800H 16GB GTX1650 Win 11 64
Love, Hope, Strength http://www.lovehopestrength.co.uk
User avatar
Shando
Skyline Moderator
Skyline Moderator
 
Posts: 560
Joined: 06 Mar 2013, 22:35
Location: Moffat Beach, Queensland
Skill: Programmer
Skill: Scripter
Skill: Level Designer

Re: require()

Postby ant0N » 14 Mar 2015, 07:44

Shando, thanks for the reply! Strange, but in all other programs (engines), it worked.
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: require()

Postby SolarPortal » 14 Mar 2015, 12:05

i think there is a function called doFile()

http://luatut.com/dofile.html
This link may help, when we tried it, it seemed to work

this has worked for us in the past.
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: require()

Postby StarFire » 14 Mar 2015, 14:49

I have used this a few times to include shared functions.
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: require()

Postby ant0N » 14 Mar 2015, 14:53

Yes thank you, it works!
I knew about dofile(), but I was afraid to use it because Skyline Script Editor does not highlight it. :lol:
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 6 guests

cron