Skip to content

Question about spacing

I have a line being spoken by an NPC, but it gets all smooshed together... here, I'll show you...
void main()
{

    object oPC = GetEnteringObject();
    if (!GetIsPC(oPC)) return;

    if (GetIsDay() || GetIsDawn())
    {
        AssignCommand(GetObjectByTag("JOHNSON"), ActionSpeakString
        ("Lovley day, don't you think" + GetName(oPC) + "?"));
    }
    else if (GetIsDusk() || GetIsNight())
    {
        AssignCommand(GetObjectByTag("JOHNSON"), ActionSpeakString
        ("Lovley evening, don't you think" + GetName(oPC) + "?"));
    }
}

It gets crammed together between the words "think" and GetName() so it reads : "Lovely evening, don't you thinkAluvian Darkstar?" How do I fix this so it's presentable?

Thanks guys...

Comments

  • KamirynKamiryn Member Posts: 74
    Add a space (' ') after 'think':
    ..., ActionSpeakString
            ("Lovley day, don't you think " + GetName(oPC) + "?")...
    
  • ZephiriusZephirius Member Posts: 411
    edited July 2022
    Oh thank you very much Kamiryn! That was really bugging me. Lol I danced around everything BUT the word think...
    Post edited by Zephirius on
  • TarotRedhandTarotRedhand Member Posts: 1,481
    edited July 2022
    FWIW You could save yourself a whole bunch of typing by the use of a single string variable with the added bonus of making your code much simpler to read -
    void main()
    {
    
        object oPC = GetEnteringObject();
        string sTimeOfDay = "evening"
        
        if (GetIsPC(oPC));
        {
            if (GetIsDay() || GetIsDawn())
                sTimeOfDay = "day";
    
            AssignCommand(GetObjectByTag("JOHNSON"), ActionSpeakString("Lovley " + sTimeOfDay +", don't you think " + GetName(oPC) + "?"));
        }
    }
    

    TR
  • ZephiriusZephirius Member Posts: 411
    Thanks for the pointer - TarotRedhand
Sign In or Register to comment.