Scripts / Scriptbank subfolders?

Author
Message
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 26th Oct 2014 22:01
It appears as though the engine includes the scriptbank subfolder name as part of the expected lua function names.

For example, I have a folder called "NewStuff" located in the scriptbank and some scripts are in it. Giving a script, we'll say "newscript.lua", in that folder to an entity (or zone) will cause an error when testing saying that it couldn't find "NewStuff/newscript_main" function.

I don't think this is intentional, but is there a known way around this until it has been fixed?


~Plystire

I'm sure there's already a thread about it somewhere, if a link could be provided, I will post there.
RustyNuts
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 9th Nov 2011
Location: Warwickshire Great Britain
Posted: 27th Oct 2014 17:13
Hi Plystire

I have encountered this very problem with a project I'm working on at the moment, and yes there is a work around. In your case what you need to do is this, Place the first line of code in the global.lua file or any other file that you are using as your main global file, and then you can call any script you want from that folder by using the second line.

package.path = "scriptbank/NewStuff/?.lua;"

require "newscript" (you don't need the .lua extension)

RustyNuts

All programmers are playwrights and all computers are lousy actors.
PM
Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 27th Oct 2014 19:06
Interesting workaround, Rusty. I wonder if it will work alongside my other required scripts that are in other places.

Thanks


~Plystire

I'm sure there's already a thread about it somewhere, if a link could be provided, I will post there.
RustyNuts
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 9th Nov 2011
Location: Warwickshire Great Britain
Posted: 27th Oct 2014 19:54
I actually have an apology to make!! I didn't read your post correctly before posting my answer and therefore I don't actually know if declaring your folder in the path statement will work when selecting a script for an entity from within Reloaded?? but with regards to it working with other folders then yes as I have several different folder all declared using said method in a global file I'm using in my project.

RustyNuts

All programmers are playwrights and all computers are lousy actors.
PM
RustyNuts
GameGuru TGC Backer
13
Years of Service
User Offline
Joined: 9th Nov 2011
Location: Warwickshire Great Britain
Posted: 28th Oct 2014 06:08 Edited at: 28th Oct 2014 06:10
Hi Plystire



just an update.... with regards to your original post about setting scripts when in Reloaded using another folder, I have just tried it and it doesn't work. I set a path to my folder in the 'Global.lua' file but like you I got an error saying it cannot find my 'main' function.



Sorry!!!



RustyNuts

All programmers are playwrights and all computers are lousy actors.
PM
Scene Commander
Support Manager
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 28th Oct 2014 13:34
Hi,

Currently subfolders aren't supported for various reasons. I'll make a note of this, as let's face it, it's a fairly obvious requirement. I doubt it will go down as a major priority at present as we've now moved onto improving game play elements and the scripting requirements do currently work, even if they aren't mainstream.

SC

i7-4770s 3.10ghz - Geforce GTX 650ti
tomjscott
User Banned
Posted: 28th Oct 2014 14:42
SC, I don't mean to sound harsh, but I will be blunt. If Lee can occasionally whip up an entire new feature such as ambient occlusion in a single day or 2, then why can't someone just spend 5 minutes to fix a trivial issue like this?

System Specs: OS - Windows 7 Home Premium 64-bit SP1, CPU - AMD Phenom II X4 945, 3.0Ghz, RAM - 8Gb DDR3, GFX Card - 2048MB NVIDIA GeForce GT 640, FPSC-R Version - Beta 1.0085

Login to post a reply

Server time is: 2024-12-21 18:35:24
Your offset time is: 2024-12-21 18:35:24