Page 1 of 1
Changing first person models through the lua
Posted: Sun Oct 31, 2010 12:02 pm
by Marvel4
Hi!
I want to change the vehicle first person models through my lua, so I thought of something like this:
Code: Select all
SetClassProperty("cis_fly_droidgunship", "FirstPerson", "IMP\impimplc;imp_1st_cockpit_landingcraft")
But, because the cis_fly_droidgunship has multiple positions, it has also multiple FirstPersons:
Code: Select all
FLYERSECTION = "BODY"
//FirstPerson = "IMP\impimplc;imp_1st_cockpit_landingcraft"
FLYERSECTION = "TURRET1"
//FirstPerson = "rep\repsccam;rep_1st_cockpit_securitycam"
What should I do?
Re: Changing first person models through the lua
Posted: Sun Oct 31, 2010 1:23 pm
by Maveritchell
A single backslash does not work for LUA reading file hierarchy. Ex.
Code: Select all
ReadDataFile("sound\\hot.lvl;hot1gcw")
Use a double backslash to make your location correct.
Re: Changing first person models through the lua
Posted: Sun Oct 31, 2010 2:01 pm
by Marvel4
I changed it to "fpm\\IMP\\impimplc.lvl;imp_1st_cockpit_landingcraft" but it didn't work...
Is SetClassProperty right, or do I have to use SetProperty?
And how should I change the different FirstPersons? I want to have a different model for all positions. (BODY and TURRET1 etc.)
Re: Changing first person models through the lua
Posted: Sun Oct 31, 2010 2:39 pm
by Maveritchell
Marvel4 wrote:I changed it to "fpm\\IMP\\impimplc.lvl;imp_1st_cockpit_landingcraft" but it didn't work...
Is SetClassProperty right, or do I have to use SetProperty?
And how should I change the different FirstPersons? I want to have a different model for all positions. (BODY and TURRET1 etc.)
Why did you add the extra folder to your directory address? The "fpm\\" is unnecessary, unless you've changed your stock directory.
I don't know if you can change the other two. I don't know if it's possible to edit concurrent lines like that with a single-line tool like SetClassProperty. I don't think I've ever experimented with that; all I can do is tell you to play around with various different things and see what works and what does not. Consider the possibility that it may not.
Re: Changing first person models through the lua
Posted: Sun Oct 31, 2010 3:22 pm
by Marvel4
Maveritchell wrote:
Why did you add the extra folder to your directory address? The "fpm\\" is unnecessary, unless you've changed your stock directory.
Because it's reading from the _lvl_pc directory and the first person file is in _lvl_pc\fpm\imp.
I also tried using FirstPersonBODY as a property, because some heroes had WeaponName1 and WeaponName2 in their odf, while other units had this:
Code: Select all
WEAPONSECTION = 1
WeaponName = ...
WEAPONSECTION = 2
WeaponName = ...
But it didn't work...
Re: Changing first person models through the lua
Posted: Sun Oct 31, 2010 3:33 pm
by DarthD.U.C.K.
Marvel4 wrote:
Because it's reading from the _lvl_pc directory and the first person file is in _lvl_pc\fpm\imp.
why dont you load it from the side?
Re: Changing first person models through the lua
Posted: Sun Oct 31, 2010 3:36 pm
by Maveritchell
Marvel4 wrote:Maveritchell wrote:
Why did you add the extra folder to your directory address? The "fpm\\" is unnecessary, unless you've changed your stock directory.
Because it's reading from the _lvl_pc directory and the first person file is in _lvl_pc\fpm\imp.
By default it is arranged to read from that directory. You already knew this, because the .odf already reads:
Code: Select all
IMP\impimplc;imp_1st_cockpit_landingcraft
My question is this - where was the confusion, when the only thing you were told you needed to change was:
Code: Select all
IMP\impimplc;imp_1st_cockpit_landingcraft
to
Code: Select all
IMP\\impimplc;imp_1st_cockpit_landingcraft
Re: Changing first person models through the lua
Posted: Sun Oct 31, 2010 3:45 pm
by Marvel4
Because the first person file is located in the _lvl_pc\fpm\imp folder and not in the _lvl_pc\imp folder.
Likewise, ReadDataFile("sound\\hot.lvl;hot1gcw") would read from the _lvl_pc\sound folder and not the _lvl_pc\fpm\sound folder. That's why I added the fpm\.
Anyway, it doesn't really matter, because I just did a test:
I added this to the lua:
Code: Select all
SetClassProperty("cis_inf_rifleman1", "FirstPerson", "REP\reptroop;rep_1st_trooper")
(no double slash!)
And it had no problems changing the droid arms to the clone arms.
So, the only problem left is how I change the FirstPerson of the different "flyersections".
Re: Changing first person models through the lua
Posted: Sun Oct 31, 2010 4:20 pm
by Maveritchell
Marvel4 wrote:Because the first person file is located in the _lvl_pc\fpm\imp folder and not in the _lvl_pc\imp folder.
Likewise, ReadDataFile("sound\\hot.lvl;hot1gcw") would read from the _lvl_pc\sound folder and not the _lvl_pc\fpm\sound folder. That's why I added the fpm\.
But you are not paying attention. ReadDataFile always reads from a base directory (wherever the relevant core.lvl file is). The .odf parameter "FirstPerson,"
by default, reads from the FPM folder.
You already know this because of what the first person sections already list. After all, how could
Code: Select all
SetClassProperty("cis_inf_rifleman1", "FirstPerson", "REP\reptroop;rep_1st_trooper")
possibly work, since the first person file isn't in the "REP" folder. Right?
A little context goes a long way.
That was boneheaded of me to suggest the double slash as necessary, though, since you're right, it is just a parameter in a callback - the .lua itself isn't reading it (although it will work that way, it's not necessary).
For your other problem, you can't just make up parameters like you did above. Both "WeaponName" and "WeaponName1" are valid parameters, which is why they both work. There is no such thing as "WeaponSectionBODY" as a parameter - read through fred's "ODF Parameters" doc.
Re: Changing first person models through the lua
Posted: Sun Oct 31, 2010 4:29 pm
by Marvel4
Ah, ok, now I understand it, sorry.
So, I assume it's not possible to change the different FirstPersons through the lua?
Re: Changing first person models through the lua
Posted: Sun Oct 31, 2010 4:36 pm
by Teancum
I can't answer whether you can or not, but there's two things to consider:
1-The model change is unlikely to take effect until the character respawns
2-It would change for the entire character class, not individual units