This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [QUESTION] Lua script help needed.  (Read 1128 times)

flagg78

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 140
    • View Profile
[QUESTION] Lua script help needed.
« on: February 03, 2014, 11:47:08 pm »
ok im not fluent in any code but have done some programing long ago. with out going into all the back story of why, all i want to do is to have a different background model for males and females in the character select and creation screens. I have narrowed it down to the GlueParent.lua. in fact its this section here:
Code: [Select]
function SetBackgroundModel(model, name)
    local nameupper = strupper(name);
    local path;
    SetSelectedSex(sex);
    if ( sex == SEX_MALE ) then
path = "Interface\Glues\Models\UI_"..name.."\UI_"..name.."_Male.m2";
    else
path = "Interface\Glues\Models\UI_"..name.."\UI_"..name.."_Female.m2";
    end
if ( model == CharacterCreate ) then
SetCharCustomizeBackground(path);
else
SetCharSelectBackground(path);
end
PlayGlueAmbience(GlueAmbienceTracks[nameupper], 4.0);
SetLighting(model, nameupper)
end

this is of course my edited version. since i dont know lua at all i dont know the syntax where im going wrong.
right now i get an error for the setselectedsex line. if i take it out the game will load fine but it always points to the female background model. never the male. i dont know quite what im doing wrong and could use some help. Thanks.

ok also tried this:
Code: [Select]
function SetBackgroundModel(model, name)
    local nameupper = strupper(name);
    local pathm = "Interface\Glues\Models\UI_"..name.."\UI_"..name.."_Male.m2";
    local pathf = "Interface\Glues\Models\UI_"..name.."\UI_"..name.."_Female.m2";
if ( model == CharacterCreate ) then
if ( sex == SEX_MALE ) then
SetCharCustomizeBackground(pathm);
else
SetCharCustomizeBackground(pathf);
end
else
if ( sex == SEX_MALE ) then
SetCharSelectBackground(pathm)
else
SetCharSelectBackground(pathf)
end
end
PlayGlueAmbience(GlueAmbienceTracks[nameupper], 4.0);
SetLighting(model, nameupper)
end

same result. always female background model.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Ascathos

  • Moderators
  • Creator of Worlds
  • *****
  • Posts: 1129
    • View Profile
Re: [QUESTION] Lua script help needed.
« Reply #1 on: February 04, 2014, 12:05:51 am »
I am not sure what variables they are, but is it SEX_MALE ? Iirc, it's sex == MALE
Correct me if I'm wrong.


EDIT:

Code: [Select]
function SetBackgroundModel(model, name)
    local nameupper = strupper(name);
    local gender;
    SetSelectedSex(sex);
    if ( sex == SEX_MALE ) then
      gender = "male";
    else
 gender = "female";
    end
    local path = "Interface\Glues\Models\UI_"..name.."\UI_"..name.."_"..gender..".m2";
   if ( model == CharacterCreate ) then
      SetCharCustomizeBackground(path);
   else
      SetCharSelectBackground(path);
   end
   PlayGlueAmbience(GlueAmbienceTracks[nameupper], 4.0);
   SetLighting(model, nameupper)
end

Does this help? Not sure, would be a test worth to me.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

flagg78

  • Contributors
  • Wiki Incarnate
  • *****
  • Posts: 140
    • View Profile
Re: [solved] fix for creation screen and large models.
« Reply #2 on: February 04, 2014, 12:23:40 am »
i did it...sort of. ill post it here and why so if someone wants to they can do it also.
     ok so mainly i wanted it for the creation screen so i can alter the attachment points to the background models to allow for large character models. i will take the coords for the character attachment and just move it back or down to allow for large toons. i dont have any playable females. i replaced them to make room for more races. i dont play females anyway and its just me here. so here is the edit i made for the glueparent.lua.


function SetBackgroundModel(model, name)
    local nameupper = strupper(name);
    local path = "Interface\Glues\Models\UI_"..name.."\UI_"..name..".m2";
   if ( model == CharacterCreate ) then
      local path = "Interface\Glues\Models\UI_"..name.."\UI_"..name.."_"..gender..".m2";
      SetCharCustomizeBackground(path);
   else
      SetCharSelectBackground(path);
   end
   PlayGlueAmbience(GlueAmbienceTracks[nameupper], 4.0);
   SetLighting(model, nameupper)
end

this way it will use the normal background on the select screen but altered ones when creating a character. to allow setting facial features and stuff. there might be a better way but this is the one i could find. thanks Ascathos.  i couldnt have managed it out without your help. as i said, im no coder.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »