Assuming I understand what is going on in Examine.xml, how do I determine what it is pulling back as the Description, format, values, line break, etc, when you rt-click and examine something.
The OnAdd script lists as OnAdd=UIScene_OnAdd_AddExamineScreen(“EXAMINE_NAME_TEXT”,“EXAMINE_DESCRIPTION_TEXT”,“IDENTIFY_BUTTON”)
Lower in the examine.xml, it shows the Name, a horizonal line, then that Description text as being displayed.
How do I control what is returned by the function that queries an item for description, plus seems to build a list of its properties.
Can I control what properties it returns, how it lists them and so on?
I should probably ask the real question I’m trying to get at; how do I modify the examine.xml, and replace whatever it’s doing to generate and pull a string with my own function that creates and returns a description string?
I can write the function that generates and returns a string with what information I want to be seen when you rt-click and Examine an item or placeable, but I’m having hard time grasping how the form displays the return string of a function.
Note that "kL_EXAMINE_EFFECTS" is the name of the UIText element that sEffects appears in ( but name your UIText-element whatever you want ofc )
you might have problems with string GetDescription(object oTarget) (if you use it) … iirc it doesn’t like to return the description on a blueprint, only text that has been set with void SetDescription(object oTarget, string sDescription)
ps. make sure that the width/height of the text element(s) are large enough, else the text in that element won’t show at all.
EDIT: See also my potentially easier post solution below this post.
Bottom line for me: I could not find it. If I could, then it would allow me to tidy my own code and have saved me around a year’s worth of coding around the problem (if you include the bug fixing time).
I needed to have the xml return the description string text to allow me to update my description pane in my inventory XML. It would have been great to find that and do one simple call, but to this day, it has evaded me, and as @kevL_s suggested, I believe it is most likely hard-coded. If you or another should discover it elsewhere, then I would also be pleased to know, as I could, perhaps, make my own code a lot more efficient.
If you want to see what I did to make use of it, check out my module …
WARNING: It does some crazy stuff, involving a lot of careful timing, and then has other points to consider throughout. Bottom line: It involves scripts executing and referencing scripts under careful timing.
Also, maybe you posting your scripts to date may give more of an idea of where you are heading and what it is you are actually trying to do? Or, can you explain what it is you are trying to do in a more gameplay way of describing?
P.S. It’s hard to understand exactly what it is you have currently done. I mean, if you have managed to get a description string returned, then that would suggest you have mastered something, but then it’s not clear as you then say you do not know how to use it. Some clarity required please.
P.P.S. If, it is as I originally think you mean it, then my first answer stands.
My steps were along these lines … (very much simplified) …
Force an examine, which generates the “description” text.
Actually, having read this again, I’ll answer in another way … although see my post above too.
As @kevL_s says, you can use SetDescription to add whatever text you require. BUT, this function does not work, unless you have removed/edited the original text from said object/item in the toolset at build time, or, iirc, you do an initial examine action. Then GetDescription works to retrieve it again.
Therefore, subject to what you are aiming to do, the solution ranges between “easy” to “difficult”. Let us know.
Thank you both for very quick replies and all the great information, I appreciate it!
Goal is to allow player to Examine an item or a placeable (right-click it, select Examine) and have the returned text be dynamic, and produced by a function I write that returns a string.
It does not necessarily need to use the Description, identified or not, that you set on the Item or Placeable from within the toolset. The returned text displayed on the Examine.xml might be based on player’s intelligence, or their appraise skill, or race, or quest states, etc. I have not completely developed those standards yet, or how complex I want to make this.
What I want, essentially, is to not have a simple boolean of “identified” determine what a player sees when they examine things.
That’s the short answer. I can go on for many more paragraphs of details if you want!
and speaking of such, how hard is it to create a completely new right-click context option called “Appraise” that opens up its own xml form lol?
Thank you for the information.
I wanted to use this concept for many things, but I’ll describe what I wanted in terms of crafting
Some found items are purely reagents for crafting. Let’s say Venison, Turnip, Salt, Chicken Liver are all ingredients used in provisioning. In a very simple example, player examines the Venison and the “Examine” text will return what known provisioning recipes using Venison the player knows, as well as the approximate gold value if player doesn’t care about crafting and just wants to sell.
The reagent items all have a preset variable stored on them, nCraftType, whose value refers to what information is checked when Examined. Example, nCraftType == 2 denotes this is a Provisioning ingredient.
The called examine function will check the local int on the item being examined, pull out nCraftType and check case of nCraftType == 2 to put together the string to return.
Something along lines of:
Venison
Type: Provisioning
Value: 30 gp
Recipes: Venison Stew, Roast Venison, and so on
EDIT: I know what I’m describing is not complicated and sounds like could just enter that text in the Description of the reagent. But this is just a simple example, I have more complicated ideas for it that wouldn’t work with static text entered in the toolset.
The examine GUI - where to begin… I have had a love-hate relationship when altering code with this xml and its related contextmenu.xml. Bottom line, they can get quite involved, but what you are after may be reasonably straightforward. It’s hard to tell at this stage.
By the way, if you have not yet done much with xml coding, then I strongly recommend my XML tutorial. And, as I say in the first post, if you want to see some examples of homebrew coding around these two xml’s, then take a look at my module.
If I understand your example, here you would edit the basic item in the toolset to have whatever description you want to have on it as a general rule. Then, when you have done this, it effectively “unlocks” the ability for you to use the SetDescription and GetDescription functions.
Then, if I understand you correctly, the next stage is to update that text depending upon the PC that examines the item if/when they examine it. Unfortunately, I have changed where that info is displayed in my campaign, and so extra explanation will be out of context for you. However …
Basically, you could also add lines of text to the basic Examine GUI, which you then add or remove via the string you wish to add/alter. Let me give you an example by posting a direct copy of a script I use in my own setup, which may give you the idea of what I am trying to explain… but do not let it confuse you, I hope. It purely serves as an example, and would not be of any use to you in any other way.
The point is, you may be best just adding additional EXAMINE PANES that you can add extra texts to, which are updated according to when you choose to.
I hope this helps… ask if you have any questions. (I may have totally misunderstood what you are after.)
BTW, not sure why this does not post properly.
///////////////////////////////////////////////////////////////////////////////////////////////////
// Adds extra text to creatures/items main description, By Lance Botelle. (Edited EXAMINE GUI also.)
// Added TEXT is assigned either PERMANENT (DEFAULT) or TEMPORARY status.
// NB: ITEMS: SINGLE TARGET SPECIFIC : DO NOT USE WITH STACKED ITEMS. Tag and variables are preserved.
// PERMANENT texts can normally be appended. A SINGLE TEMPORARY text must be updated as required.
// TEXT IS INSERTED AFTER NORMAL DESCRIPTIVE TEXT: "PERMTEXT" + "TEMPTEXT". (THEN ANY ITEM PROPERTIES.)
///////////////////////////////////////////////////////////////////////////////////////////////////
// CREATURES USE OF XML EXTRA PANE CALLED "POST_DESCRIPTION_TEXT"
// A) A PERMANENT text is normally set only once. (Theorhetically could be changed as required.)
// B) TEMPORARY TEXTS USED FOR ANY CURRENT EFFECTS THE CREATURE HAS ON THEM AT EXAMINE TIME ONLY!
///////////////////////////////////////////////////////////////////////////////////////////////////
// ITEMS JUST APPEND THIER NORMAL DESCRIPTION UPDATED WHEN CLICKED ON. "ITEMDECS" UPDATES.
// A) PERMANENT texts are normally appended to any exisiting such texts as required.
// B) TEMPORARY text can only be ONE at a time, so apply sparingly. (NB; Properties handled elsehwere.)
///////////////////////////////////////////////////////////////////////////////////////////////////
void LBAddToDescription(object oTarget, string sTextAdd = "", int iItemTemp = 0);
void LBAddToDescription(object oTarget, string sTextAdd = "", int iItemTemp = 0)
{
// CREATURE POST DESCRIPTION TEXT IS ALWAYS PERMANET THIS WAY. (CAN OVERWRITE)
if(GetObjectType(oTarget) == OBJECT_TYPE_CREATURE)
{
SetLocalString(oTarget, "POSTDESCTEXT", sTextAdd);
}
else
{
string sPERMPLUS = GetLocalString(oTarget, "PERMTEXT");
string sTEMP = GetLocalString(oTarget, "TEMPTEXT");
// UPDATE (OR ADD TO) A PERMANENT TEXT
if(iItemTemp == 0)
{
// DO NOT DUPLICATE ANY POTENTIAL EXISTING TEXT
if(FindSubString(sPERMPLUS, sTextAdd) == -1)
{
sPERMPLUS = sPERMPLUS + "\n" + sTextAdd;
SetLocalString(oTarget, "PERMTEXT", sPERMPLUS);
}
else
{
return;
}
}
// UPDATE TEMP TEXT
else if(sTextAdd != "")
{
// CAN ONLY BE ONE INSTANCE FOR ITEMS (OVERWRITES)
SetLocalString(oTarget, "TEMPTEXT", sTEMP);
sTEMP = sTextAdd;
}
// DELETE TEMP TEXT
else
{
DeleteLocalString(oTarget, "TEMPTEXT");
sTEMP = "";
}
// UPDATE STRING VARIABLE
if(sPERMPLUS != "" && sTEMP != ""){sPERMPLUS = sPERMPLUS + "\n" + sTEMP;}
else if(sPERMPLUS == ""){sPERMPLUS = sTEMP;}
SetLocalString(oTarget, "POSTDESCTEXT", sPERMPLUS);
DeleteLocalString(oTarget, "ITEMDECS");
}
}
And here is a snippet of the examine.xml where it is used…
In the script, I’m having trouble getting the object that I right-clicked to Examine.
OBJECT_SELF gives the PC, GetItemActivated did not work.
How do I know the inventory item I right-clicked in that gui_examine script?
on my Examine, some data gets printed custom. The basic answer is GetPlayerCurrentTarget() – but then you might want to distinguish the target’s, uh, circumstances … eg. is it a Creature, is it an item in a store, etc →
Another potential issue you’ll encounter is that this stays active until the player selects a new target. Otherwise, as KevL says, use GetPlayerCurrentTarget.
I haven’t read all posts here that thoroughly, but I have a question that is kind of connected to this:
If the PC clicks and examines a placeable, could one place a script that activates when that happens? Could you perhaps use GetLastUsedBy(); in a script (on the OnUsed event) for that, or does right-clicking on an object not count as it being used?
Yes, I have added extra code at the end of my own gui_examine that can (and does) do this. If I recall correctly (as it has been some time since I last looked at this area of code closely), it was part of the general complication of getting everything to work together with these hooks.
Fired via Examine Open and then using GetPCCurrentlyControlled.