Attempting to replicate user_script.lvl support

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
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Attempting to replicate user_script.lvl support

Post by AnthonyBF2 »

Zerted informed me that the script game_interface.lua inside of ingame.lvl is what detects and runs user_script.lvl files, if they are detected. Since he is not so active I must bring this to open forum and see about getting help elsewhere.

I have tried two things in my game_interface.lua but none are working.

The first attempt is to see if the game can find user_script_1.lvl and attempt to run it. It did not work.

Code: Select all

if ScriptCB_IsFileExist("user_script_1.lvl") then
ReadDataFile("user_script_1.lvl")
end
The second code I tried is just directly reading the file, also did not work.

Code: Select all

ReadDataFile("user_script_1.lvl")
My contents of user_script_1.lvl are

Code: Select all

OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
MissionVictory(1,2)
end
end
)
So if everything were to be working, the game should skip to victory as soon as player spawns, but it's not happening. Thanks for any help!
Last edited by AnthonyBF2 on Fri Mar 11, 2016 9:07 pm, edited 2 times in total.
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: Attempting to replicate user_script.lvl support

Post by Maveritchell »

Does it work to pass in two inputs to MissionVictory? Are you sure your userscript works?
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: Attempting to replicate user_script.lvl support

Post by Anakin »

Please add print("userscript 1 entered") at the top of your user script 1 to make sure that it is loaded correctly. Maybe your execute path of game_interface is not the same where your script is.

An other way is to add a output to your if condition, to make sure it returned 1 and not 0.
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: Attempting to replicate user_script.lvl support

Post by AnthonyBF2 »

MissionVictory(1,2) does work and I cannot use print because this mod is for PS2 and it doesn't have debugging.
User avatar
commanderawesome
Field Commander
Field Commander
Posts: 971
Joined: Tue Aug 13, 2013 11:58 pm
Projects :: Skin Changer - Warfront - Other stuff
Games I'm Playing :: SWBF SWTOR KotOR EaW
xbox live or psn: AaTc_CmdrAwesome
Location: The Universe

Re: Attempting to replicate user_script.lvl support

Post by commanderawesome »

Try this for loading the script:

Code: Select all

ReadDataFile("user_script_1.lvl")
ScriptCB_DoFile("user_script_1")
User avatar
AnthonyBF2
Sith
Sith
Posts: 1255
Joined: Wed Aug 21, 2013 3:55 pm
Projects :: PS2+PSP Overhaul

Re: Attempting to replicate user_script.lvl support

Post by AnthonyBF2 »

commanderawesome wrote:Try this for loading the script:

Code: Select all

ReadDataFile("user_script_1.lvl")
ScriptCB_DoFile("user_script_1")
Yes! That makes it work, thanks!!! :mrgreen:

I have a situation with that code you posted commanderawesome, the game only works when a user script file is found. If there are none found, the game crashes at load screen.

I tried using;

Code: Select all

if ScriptCB_IsFileExist("user_script_1.lvl") then
	ReadDataFile("user_script_1.lvl")
	ScriptCB_DoFile("user_script_1")
end
But that didn't work. It still crashes if a user script file isn't found.
Post Reply