Hey,
i'm looking forward to do some scripting, but i'm not 100% sure how to do so, or if this is even possible.
So what i need ist:
1) browsing directories and get folder names,
2) string manipulation,
3) check if a file exist,
4) load that file if it does exist.
specialy for 1) and 2) i'm not sure how to do so
advanced lua scripting
Moderator: Moderators
- Anakin
- Master of the Force
- Posts: 4817
- Joined: Sat Sep 19, 2009 11:37 am
- Projects :: RC Side Mod - Remastered - SWBF3 Legacy
- Location: Mos Espa (germany)
-
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: advanced lua scripting
Unfortunately Lua doesn't come with any file system libraries, and SWBF2's Lua implementation lacks the I/O library (among others).Anakin wrote:1) browsing directories and get folder names,
What specifically are you trying to do with strings? See here: https://www.lua.org/pil/20.htmlAnakin wrote:2) string manipulation,
See `ScriptCB_IsFileExist(filePath)`, which returns true if a file at the specified path exists, or nil if not. As for loading the file, you'd obviously want `ReadDataFile(lvlFilePath)` or `ScriptCB_DoFile(scriptFilePath)` depending on the file type.Anakin wrote:3) check if a file exist,
4) load that file if it does exist.
- Anakin
- Master of the Force
- Posts: 4817
- Joined: Sat Sep 19, 2009 11:37 am
- Projects :: RC Side Mod - Remastered - SWBF3 Legacy
- Location: Mos Espa (germany)
Re: advanced lua scripting
to avoid the user and GC script conflicts I thought of an user and GC script that search in all subfolders from the addon folder for a special file and load it.
Let's say this way:
addon\XXX\scripts\xxx_scripts.lvl (GC script)
Addon\xxx\scripts\xxx_ingame.lvl (userscript)
So I need to get a list of folder names (xxx) and manipulate a string to build the total path where I wanna search for the file and (if it exist) load it
Let's say this way:
addon\XXX\scripts\xxx_scripts.lvl (GC script)
Addon\xxx\scripts\xxx_ingame.lvl (userscript)
So I need to get a list of folder names (xxx) and manipulate a string to build the total path where I wanna search for the file and (if it exist) load it
-
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: advanced lua scripting
Unfortunately you can't.Anakin wrote:So I need to get a list of folder names (xxx) and manipulate a string to build the total path where I wanna search for the file and (if it exist) load it
However, I wrote a batch script for MEU that installs user scripts/GCs by looking through existing ones by name and installing it in the first available "slot". The script is here: https://www.dropbox.com/s/h6dup8qht2wxz ... s.zip?dl=0
To use it, you just pass an argument to the script with a value of either `custom_gc` or `user_script`. You'll also need to edit BIN_DIR, USERSCRIPTS_DIR, and TEMP_DIR to reflect your own project.