Move files via Lua

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Anakin
Master of the Force
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)

Move files via Lua

Post by Anakin »

Hi,

does someone know how to move files via lua??
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Re: Move files via Lua

Post by Teancum »

I doubt you can. As it would be an easy way to break someone's game programmers usually don't allow for things like this.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Move files via Lua

Post by Maveritchell »

Teancum wrote:I doubt you can. As it would be an easy way to break someone's game programmers usually don't allow for things like this.
More specifically, you can move/edit files with Lua, you just can't with SWBF2's lua scripts. Most of the file I/O and OS libraries are disabled in SWBF2's mission scripts, in my experience.
User avatar
Anakin
Master of the Force
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: Move files via Lua

Post by Anakin »

it's a shame. I don't wanted to break someones work, i wanted to install my galactic conquest on the first start.

Code: Select all

if ScriptCB_IsFileExist("..\\..\\addon\\RCM\\data\\_LVL_PC\\custom_gc_5.lvl") == 1 then
    if ScriptCB_IsFileExist("custom_gc_5.lvl") == 1 then
		print("RCM: WARNING - custom_gc_5.lvl already exists.")
	else
		print("RCM: custom_gc_5.lvl installed. Restart to apply changes.")
		os.move("..\\..\\addon\\RCM\\data\\_LVL_PC\\custom_gc_5.lvl","custom_gc_5.lvl")
	end
end
is it possible to write an external program/script and start it from the lua script?? so for example an bat file??
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: Move files via Lua

Post by [RDH]Zerted »

The only file creation/deletion you can do is through game saves and profile saves. Everything else has been disabled, likely to protect users. What you can do is create an installer that lets the user choose to install your galactic conquest. For reference, here's the v1.3 Inno Setup installation script:
Hidden/Spoiler:
[code]#define Dir "\GameData\addon\AAA-v1.3patch"
#define ModTools "C:\dev\BF2_ModTools\data_AAA\ready"

[Setup]
AppName=Unofficial v1.3 Patch
AppId=Unofficial v1.3 Patch
AppVerName=Unofficial v1.3 Patch r129
AppVersion=1.3.129
AppPublisher=Zerted
AppPublisherURL=http://zerted.getmyip.com/
AppSupportURL=http://zerted.getmyip.com/
AppUpdatesURL=http://zerted.getmyip.com/
Compression=lzma/ultra64
DefaultDirName={reg:HKLM\SOFTWARE\LucasArts\Star Wars Battlefront II\1.0,ExePath|c:\Program Files\Star Wars Battlefront II\GameData\BattlefrontII.exe}\..\..\
InternalCompressLevel=ultra
ShowTasksTreeLines=True
ShowLanguageDialog=no
SolidCompression=True
Uninstallable=False
VersionInfoVersion=1.3.129
VersionInfoProductVersion=1.3.129
VersionInfoProductName=Unofficial v1.3 patch
OutputBaseFileName=setup
;OutputBaseFileName=SWBF2 Unofficial v1.3 r129 patch installer
;OutputDir=
OutputManifestFile=setup-manifest.txt
DirExistsWarning=no
InfoBeforeFile={#ModTools}\docs\installer-extra-info.txt
TouchDate=none
TouchTime=none
WindowResizable=yes

[Types]
Name: "max"; Description: "Most changes"
Name: "default"; Description: "Common changes"
Name: "min"; Description: "Least changes"
Name: "custom"; Description: "Custom changes"; Flags: iscustom

[Components]
Name: useNewHud; Description: Use the v1.2 HUD; Types: max
Name: noAwards; Description: Disable awards' graphical effects; Types: default max
Name: noColors; Description: Disable custom map colors; Types: min
Name: noChecker; Description: Disable the Mission Limit Checker (not recommended); Types: min
Name: useDocs; Description: Include the detailed docs and modding guides; Types: default max

[Dirs]
Name: "{app}\{#Dir}";
Name: "{app}\{#Dir}\settings";
Name: "{app}\{#Dir}\docs"; Components: useDocs
Name: "{app}\{#Dir}\docs\howtos"; Components: useDocs
Name: "{app}\{#Dir}\docs\code samples"; Components: useDocs


[Files]
;Readme
Source: {#ModTools}\readme.txt; DestDir: {app}\{#Dir}; Flags: isreadme ignoreversion

;Mission limit checker
Source: {#ModTools}\addme.script; DestDir: {app}\{#Dir}; Flags: ignoreversion; Components: not noChecker

;Setting files
Source: {#ModTools}\noAwards.txt; DestDir: {app}\{#Dir}\settings; Flags: ignoreversion; Components: noAwards
Source: {#ModTools}\noColors.txt; DestDir: {app}\{#Dir}\settings; Flags: ignoreversion; Components: noColors

;Standard documents
Source: {#ModTools}\docs\credits.txt; DestDir: {app}\{#Dir}; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\docs\installer-extra-info.txt; DestDir: {app}\{#Dir}; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\docs\changelog - common.lvl.txt; DestDir: {app}\{#Dir}\docs; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\docs\changelog - ingame.lvl.txt; DestDir: {app}\{#Dir}\docs; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\docs\changelog - shell.lvl.txt; DestDir: {app}\{#Dir}\docs; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\docs\changelog - user_script_10.lvl.txt; DestDir: {app}\{#Dir}\docs; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\docs\changelog - custom_gc_10.lvl.txt; DestDir: {app}\{#Dir}\docs; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\docs\cheatbox codes.txt; DestDir: {app}\{#Dir}\docs; Flags: ignoreversion; Components: useDocs

;Tutorials
Source: {#ModTools}\howtos\Add A Preivew Video.txt; DestDir: {app}\{#Dir}\docs\howtos; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\howtos\Add An Era.txt; DestDir: {app}\{#Dir}\docs\howtos; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\howtos\Add Custom Map Colors.txt; DestDir: {app}\{#Dir}\docs\howtos; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\howtos\Adding A Custom Galactic Conquest.txt; DestDir: {app}\{#Dir}\docs\howtos; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\howtos\Change an Era's and Game Mode's Name or Icon or Description.txt; DestDir: {app}\{#Dir}\docs\howtos; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\howtos\Make Custom User Scripts.txt; DestDir: {app}\{#Dir}\docs\howtos; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\howtos\Munge A Custom LVL File.txt; DestDir: {app}\{#Dir}\docs\howtos; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\howtos\Using Ingame Player Data.txt; DestDir: {app}\{#Dir}\docs\howtos; Flags: ignoreversion; Components: useDocs

;Code Samples
Source: {#ModTools}\code samples\custom_gc_example.zip; DestDir: {app}\{#Dir}\docs\code samples; Flags: ignoreversion; Components: useDocs
Source: {#ModTools}\code samples\user_script_example.zip; DestDir: {app}\{#Dir}\docs\code samples; Flags: ignoreversion; Components: useDocs

;LVL files
Source: {#ModTools}\common.lvl; DestDir: {app}\GameData\data\_lvl_pc; Flags: ignoreversion
Source: {#ModTools}\v1.2\ingame.lvl; DestDir: {app}\GameData\data\_lvl_pc; Flags: ignoreversion; Components: useNewHud
Source: {#ModTools}\ingame.lvl; DestDir: {app}\GameData\data\_lvl_pc; Flags: ignoreversion; Components: not useNewHud
Source: {#ModTools}\shell.lvl; DestDir: {app}\GameData\data\_lvl_pc; Flags: ignoreversion
Source: {#ModTools}\v1.3patch_strings.lvl; DestDir: {app}\GameData\data\_lvl_pc; Flags: ignoreversion

;'Patch' files for r117+ source code
Source: {#ModTools}\user_script_10.lvl; DestDir: {app}\GameData\data\_lvl_pc; Flags: ignoreversion
Source: {#ModTools}\custom_gc_10.lvl; DestDir: {app}\GameData\data\_lvl_pc; Flags: ignoreversion

;Preview movie
Source: {#ModTools}\pre-movie.mvs; DestDir: {app}\GameData\data\_lvl_pc\movies; Flags: ignoreversion

[InstallDelete]
;removes all older v1.3 related files
Type: filesandordirs; Name: "{app}\{#Dir}"
Type: filesandordirs; Name: "{app}\docs"
Type: filesandordirs; Name: "{app}\GameData\data\_lvl_pc\v1.3 docs"
Type: files; Name: "{app}\GameData\data\_lvl_pc\FC_Mod_Strings.lvl"
Type: files; Name: "{app}\GameData\data\_lvl_pc\v1.3patch_strings.lvl"
Type: files; Name: "{app}\GameData\data\_lvl_pc\user_script_10.lvl"
Type: files; Name: "{app}\GameData\data\_lvl_pc\custom_gc_10.lvl"
Type: files; Name: "{app}\GameData\data\_lvl_pc\movies\pre-movie.mvs"
;remove v1.2 files that deal with ingame.lvl, as v1.3 is taking over ingame.lvl
Type: files; Name: "{app}\GameData\data\GET_RID_OF_HUD.bat"
Type: files; Name: "{app}\GameData\data\RESTORE_HUD.bat"
Type: files; Name: "{app}\GameData\data\_lvl_pc\1-2_nohud_ingame.lvl"
Type: files; Name: "{app}\GameData\data\_lvl_pc\1-1_ingame.lvl"[/code]
Post Reply