edited November 12 in ORK Scripting
Gil,
How do you set a player name via script?
I know I want Index 0,1,2, and 3

I want to set it via my own gui.

I see there is a Schematics.Nodes.SetCombatantNameNode
But I don't want to use the schematics editor for this.

I want to set Name, Gender and Class on the 1st 4 combatants, immediately at game start. And just replace the placeholder prefabs listed on the Combatants page entirely.

If I had to do this via the Schematics editor it would have several branching chains and it would very quickly get out of control. I struggle with node editors on the best of days, so was hoping to just script it manually.

Ideas?
Post edited by paulgswanson on
  • edited November 12
    Was kind of hoping to find something along the lines of this:
        ORKFramework.Combatant CBT1 SetName = CBT1_Name.ToString()
    ORKFramework.Combatant CBT1 SetClass = CBT1_Class[0]
    ORKFramework.Combatant CBT1 SetPrefab = Gameobject.Female.Whitemage;
    image


    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    using TMPro;
    using GamingIsLove.ORKFramework;

    public class CharacterSelectionScreen : MonoBehaviour
    {

    #region Combatant 0 Variables
    public TMP_InputField CBT0_Name;

    public Button CBT0_Warrior, CBT0_Monk, CBT0_WhiteMage, CBT0_BlackMage, CBT0_RedMage, CBT0_Thief, CBT0_Male, CBT0_Female, CBT0_Done;
    public Image CBT0_PreviewImage;
    public bool CBT0War, CBT0MNK, CBT0WHM, CBT0BLM, CBT0RDM, CBT0THF, CBT0MALE, CBT0FEMALE;
    #endregion

    #region Combatant 1 Variables
    public TMP_InputField CBT1_Name;

    public Button CBT1_Warrior, CBT1_Monk, CBT1_WhiteMage, CBT1_BlackMage, CBT1_RedMage, CBT1_Thief, CBT1_Male, CBT1_Female, CBT1_Done;
    public Image CBT1_PreviewImage;
    public bool CBT1War, CBT1MNK, CBT1WHM, CBT1BLM, CBT1RDM, CBT1THF, CBT1MALE, CBT1FEMALE;
    #endregion

    #region Combatant 2 Variables
    public TMP_InputField CBT2_Name;

    public Button CBT2_Warrior, CBT2_Monk, CBT2_WhiteMage, CBT2_BlackMage, CBT2_RedMage, CBT2_Thief, CBT2_Male, CBT2_Female, CBT2_Done;
    public Image CBT2_PreviewImage;
    public bool CBT2War, CBT2MNK, CBT2WHM, CBT2BLM, CBT2RDM, CBT2THF, CBT2MALE, CBT2FEMALE;
    #endregion

    #region Combatant 3 Variables
    public TMP_InputField CBT3_Name;

    public Button CBT3_Warrior, CBT3_Monk, CBT3_WhiteMage, CBT3_BlackMage, CBT3_RedMage, CBT3_Thief, CBT3_Male, CBT3_Female, CBT3_Done;
    public Image CBT3_PreviewImage;
    public bool CBT3War, CBT3MNK, CBT3WHM, CBT3BLM, CBT3RDM, CBT3THF, CBT3MALE, CBT3FEMALE;
    #endregion

    // Start is called before the first frame update
    void Start() { }

    // Update is called once per frame
    void Update() { }

    #region Combatant 1 Functions
    public void CBT0_WARClick() { CBT0War = true; CBT0MNK = false; CBT0WHM = false; CBT0BLM = false; CBT0RDM = false; CBT0THF = false; }
    public void CBT0_MNKClick() { CBT0MNK = true; CBT0War = false; CBT0WHM = false; CBT0BLM = false; CBT0RDM = false; CBT0THF = false; }
    public void CBT0_WHMClick() { CBT0WHM = true; CBT0MNK = false; CBT0War = false; CBT0BLM = false; CBT0RDM = false; CBT0THF = false; }
    public void CBT0_BLMClick() { CBT0BLM = true; CBT0MNK = false; CBT0War = false; CBT0WHM = false; CBT0RDM = false; CBT0THF = false; }
    public void CBT0_RDMClick() { CBT0RDM = true; CBT0MNK = false; CBT0War = false; CBT0WHM = false; CBT0BLM = false; CBT0THF = false; }
    public void CBT0_THFClick() { CBT0THF = true; CBT0MNK = false; CBT0War = false; CBT0WHM = false; CBT0BLM = false; CBT0RDM = false; }
    public void CBT0_MaleClick() { CBT0MALE = true; CBT0FEMALE = false; }
    public void CBT0_FemaleClick() { CBT0MALE = false; CBT0FEMALE = true; }


    void CBT0ChangePlayername()
    {
    Combatant CBT0 = ORK.Game.Combatants.Get(0);
    CBT0.Setting.EditorName = CBT0_Name.ToString();
    }

    // ORKFramework.Combatant CBT0 SetName = CBT0_Name.ToString()
    // ORKFramework.Combatant CBT0 SetClass = CBT0_Class[0]
    // ORKFramework.Combatant CBT0 SetPrefab = Gameobject.Female.Whitemage

    #endregion
    }
    Post edited by paulgswanson on
  • edited November 13
    While I was waiting for a answer, i did my best coming up with a Schematic solution, however I've hit a snag.
    Is there a equipped combatant class text code? SO that once its selected the player can confirm that's what they want? Since there's no going back after the initial selection.
    Name: combatant.name=5432a9bb-1da3-4073-9401-1079ba635355
    Class:
    Post edited by paulgswanson on
  • You can set a combatant's name like this:
    combatant.RenameableName = "New Name";

    You can access the player group via ORK.Game.ActiveGroup, e.g. the player:
    Combatant player = ORK.Game.ActiveGroup.Leader;
    Or a specific member via index:
    Combatant member = ORK.Game.ActiveGroup.MemberAt(index);
    Please consider rating/reviewing my products on the Asset Store (hopefully positively), as that helps tremendously with getting found.
    If you're enjoying my products, updates and support, please consider supporting me on patreon.com!
Sign In or Register to comment.