Scripts / REQUIRE Command

Author
Message
GoDevils
9
Years of Service
User Offline
Joined: 24th Sep 2014
Location: Arizona USA
Posted: 10th Apr 2015 17:55
I need to create my own myglobal.lua. I understand that the script must be called (loaded) using the Require command.

I'm assuming that this command is placed in global.lua...correct??

If so, where in global.lua is it placed? Inside _init cycle or before _init with the other variable declarations????

Thanks
GoDevil
"THERE IS NO SPOON"

AMD 6300 6 core 3.5 ghz, Windows 8.1, 8GB ram, GTX 650 2GB ram
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 10th Apr 2015 18:24
there isnt any init(e) or anything in the global file, it's just a bunch of functions and variables
you can place it anywhere
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
GoDevils
9
Years of Service
User Offline
Joined: 24th Sep 2014
Location: Arizona USA
Posted: 10th Apr 2015 22:01
Thanks smallg
"THERE IS NO SPOON"

AMD 6300 6 core 3.5 ghz, Windows 8.1, 8GB ram, GTX 650 2GB ram
GoDevils
9
Years of Service
User Offline
Joined: 24th Sep 2014
Location: Arizona USA
Posted: 15th Apr 2015 20:44
OK, so I added this to global.lua

require("myglobal")

When it ran I got a long error indicating that I was missing a DDL named myglobal ?????

What is the proper syntax ?
Does this structure work during test game mode ?

?????
"THERE IS NO SPOON"

AMD 6300 6 core 3.5 ghz, Windows 8.1, 8GB ram, GTX 650 2GB ram
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 15th Apr 2015 22:55
the correct syntax looks like this
package.path = "scriptbank/?.lua;"
require "myglobal"

you can apparently also use the below within the init function of a specific script
Include ("ai_cover.lua")
life\'s one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
!nullptr
Forum Support
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 16th Apr 2015 00:14 Edited at: 16th Apr 2015 00:15
I simply use an object placed at the start with Always Active tied to my "fragjack" (global) script pretty similar to what smallg is saying above.

PM
perelect
9
Years of Service
User Offline
Joined: 27th Mar 2015
Location: Australia
Posted: 11th May 2015 23:28
So is this correct?

place this ....

require "myglobal"

anywhere into the global.lua

and I then make a file called myglobal,lua in the scriptbank.

and every time the global.lua is upgraded you only have to replace the

require "myglobal"

back into global.lua

So on startup global.lua is read and then myglobal.lua is read to setup the commands...






I may be old, but at least my memory still ....hmmm

Pavilion dv6 Notebook, Intel(R) Core(TM) i5-2410M CPU @ 2.30 GHz, Win 7 64 bit, 16 GB Ram, Radeon (TM) HD 6490M, 2789 MB Memory. Resolution 1366x768, Intel(R) HD Graphics 3000. (WEI 5.8)

Login to post a reply

Server time is: 2024-05-07 13:22:57
Your offset time is: 2024-05-07 13:22:57