Item Renamer/Redescriptioner?

Post suggestions for improvements here.
Post Reply
User avatar
Qui Chang
Baron
Baron
Posts: 59
Joined: Thu Aug 31, 2006 1:40 pm

Item Renamer/Redescriptioner?

Post by Qui Chang »

Wondering if you'd given any thought to adding a "/rename=" command or "/description=" command for players to rename their items. Traditionally done with listeners and storage placeables, it can now be done fairly easily as a chat command as well. It does require a little bit of set up to use the new EnterTargetingMode function. I'm not sure if you've already implemented it on BSK or not. It's pretty fun and useful. Can be used for quite a lot of stuff.

Example targeting script:

Code: Select all

void main()
{
    // Get the last player to use targeting mode
    object oPC = GetLastPlayerToSelectTarget();

    // Get the targeting mode data
    object oTarget = GetTargetingModeSelectedObject();
    vector vTarget = GetTargetingModeSelectedPosition();

    // If the user manually exited targeting mode without selecting a target, return
    if (!GetIsObjectValid(oTarget) && vTarget == Vector())
        return;


    // Save the targeting data to the PC object for later use
    //location lTarget = Location(GetArea(oTarget), vTarget, 0.0f);

    //SetLocalObject(oPC, "TARGETING_OBJECT", oTarget);
    //SetLocalLocation(oPC, "TARGETING_POSITION", lTarget);

    string sTargetMode = GetLocalString(oPC, "TARGET_MODE");
   

    //Section used for chat commands
    if (sTargetMode == "following")
    {
        AssignCommand(oPC, ActionForceFollowObject(oTarget));
    }

    else if (sTargetMode == "rename")
    {
        string sRename = GetLocalString(oPC, "RENAME_STRING");
        SetName(oTarget, sRename);
    }

    else if (sTargetMode == "description")
    {
        string sDescription = GetLocalString(oPC, "DESCRIPTION_STRING");
        SetDescription(oTarget, sDescription);
    }

    //SetLocalString(oPC, "TARGET_MODE", "");//Set target mode back to nothing. May not be needed
}
Example OnChat code:

Code: Select all

//Target Modes
        else if (sSaid == "/follow")
        {
            SetLocalString(oSpeaker, "TARGET_MODE", "following");
            SendMessageToPC(oSpeaker, "Select a person or creature to follow.");
            EnterTargetingMode(oSpeaker, OBJECT_TYPE_CREATURE);
        }
        else if (GetStringLeft(sSaid, 8) == "/rename ")
        {
            string sRemove = StringParse(sSaid, " ");
            string sName = StringRemoveParsed(sSaid, sRemove, " ");
            SendMessageToPC(oSpeaker, "Select an item to rename.");
            SetLocalString(oSpeaker, "TARGET_MODE", "rename");
            SetLocalString(oSpeaker, "RENAME_STRING", sName);
            EnterTargetingMode(oSpeaker, OBJECT_TYPE_ITEM);
        }

        else if (GetStringLeft(sSaid, 13) == "/description ")
        {
            string sRemove = StringParse(sSaid, " ");
            string sDescription = StringRemoveParsed(sSaid, sRemove, " ");
            SendMessageToPC(oSpeaker, "Select an item to change the description of.");
            SetLocalString(oSpeaker, "TARGET_MODE", "description");
            SetLocalString(oSpeaker, "DESCRIPTION_STRING", sDescription);
            EnterTargetingMode(oSpeaker, OBJECT_TYPE_ITEM);
        }


Example line to add to OnModuleLoad:

Code: Select all

//Used to set the module OnPlayerTarget event since it's not in the module properties. Have to do it manually.
    SetEventScript(GetModule(), EVENT_SCRIPT_MODULE_ON_PLAYER_TARGET, "name of module target script here");
"When the student is ready.....the master appears" Old Zen Saying
Post Reply