Skip to content

SetSkinString wiped on module reload [Solved]

CaomhCaomh Member Posts: 40
edited September 2021 in Builders - Scripting
I noticed an issue with using SetSkinString. The command works and reads when in game, but upon logging out everything is now wiped. Is there any ETA or plans on restoring that functionality for saving variables to the creature skin?

tl;dr
Using SetSkinString on the PC works while in game, but will delete when logging out. Looking for a quick and easy fix.
Post edited by Caomh on

Comments

  • meaglynmeaglyn Member Posts: 151
    Are you sure it isn't happening on login. ELC will (or at least used to) remove the skin object.
  • ForSeriousForSerious Member Posts: 466
    I have it working on mine. I think the main scripts you have to check are OnClientEnter and OnPlayerRest.
    You can do a 'Find in Files' search and check the 'Find in all Files in Module' option. Search for: #include "x3_inc_skin"
    or
    GetItemInSlot(INVENTORY_SLOT_CARMOUR,
    Try to find if there is something that's deleting the skin or replacing it with a new one.

    I don't remember if the OnClientEnter script does anything with the skin by default. I have mine set to add all the player tools if they don't already.
  • CaomhCaomh Member Posts: 40
    edited September 2021
    meaglyn wrote: »
    Are you sure it isn't happening on login. ELC will (or at least used to) remove the skin object.

    Thank you for the response. That did help me narrow down the problem.

    Reload When Empty, and reloading.

    The variables exist until the module is reloaded. When I unchecked that box the character logging off and back on kept all the variables on the skin object. Reloading did the same. I may have to go the old fashioned route and toss an object that cannot be dropped in the bag and save everything there.
    ForSerious wrote: »
    I have it working on mine. I think the main scripts you have to check are OnClientEnter and OnPlayerRest.
    You can do a 'Find in Files' search and check the 'Find in all Files in Module' option. Search for: #include "x3_inc_skin"
    or
    GetItemInSlot(INVENTORY_SLOT_CARMOUR,
    Try to find if there is something that's deleting the skin or replacing it with a new one.

    I don't remember if the OnClientEnter script does anything with the skin by default. I have mine set to add all the player tools if they don't already.

    Per the above I am wondering if I just put it on another slot that is not the skin.
  • ForSeriousForSerious Member Posts: 466
    If it's not saving when you have Reload When Empty checked, logically you would get the same result when saving variables to an undropable item. That sounds like it's triggering the module reload before saving the character.

    I have Enforce Legal Characters enabled and it does not remove the PC Properties skin.
  • CaomhCaomh Member Posts: 40
    The issue appears to not be dropping the skin. The issue seems to be removing variables saved to the skin. In my case I use those variables for checks on the skin. This sort of behavior I am told does not happen to items in the inventory.
  • ForSeriousForSerious Member Posts: 466
    That should not be happening. Admittedly, I have removed the default horse functions from my OnClientEnter script and have not tried to store strings on the skin. I am able to store int variables on it and give player tool feats with no issues.
  • CaomhCaomh Member Posts: 40
    I added the variables to an item owned by the player. The persistence remains. On the creature skin it does not. Hopefully the functionality will be restored in the future.
  • ForSeriousForSerious Member Posts: 466
    edited September 2021
    Humm.
    Here's the function in its default form:
    void SetSkinString(object oCreature,string sVariable,string sValue)
    { // PURPOSE: SetSkinString
        object oSkin;
        if (GetIsPC(oCreature)) oSkin=SKIN_SupportGetSkin(oCreature);
        else
        { // npc
            oSkin=GetItemPossessedBy(oCreature,"x3_it_pchide");
            if (GetIsObjectValid(oSkin)) DestroyObject(oSkin);
            oSkin=oCreature;
        } // npc
        string sVar=StringReplace(sVariable,"_","");
        SetLocalString(oSkin,sVar,sValue);
    } // SetSkinString()
    

    My suggestion: Don't use it.

    This is how I do it:
    Here's a little script that I put in a conversation:
    #include "x3_inc_skin"
    void main()
    {
      object oPC = GetPCSpeaker();
      object oSkin = SKIN_SupportGetSkin(oPC);
      string sString = GetLocalString(oSkin, "Time");
      SendMessageToPC(oPC, sString);
      int iNum = StringToInt(sString);
      SetLocalString(oSkin, "Time", IntToString((iNum + 5)));
    }
    

    Of course the number doesn't increase when I run Test Module from within the toolset. That's because the character file used is not saved. It works in normal use though.
Sign In or Register to comment.