Jump to content
  • entries
    74
  • comments
    426
  • views
    1446538

UIObject_Misc_ExtractData


By Rich Taylor

 

A new callback in 1.06 is:

UIObject_Misc_ExtractData( sourceobject, datatype, index, destinationvar )

 

This callback can be used to extract the data imbedded by the engine within UI Objects. First I'll go over the parameters, then I'll give some examples.

 

sourceobject

This parameter is used to define which UI Object we are extracting data from. It accepts the following options:

 

selected:listboxname - By replacing 'listboxname' with the name of the listbox you're interested in, you can tell this callback to use the selected row within the list box as the source of the data.

 

self: - By using 'self:', you are telling the callback to use the object that invoked the callback as the source from which to extract the data.

 

context:uiobject - By using context:uiobject:', you are telling the callback to use the UI Object that invoked the context menu. This obviously only means anything if the callback is being called from a context menu node. If called from anywhere else, the callback will do nothing.

 

objectname - If you enter any string besides the above 3 options, the callback will search for a UIObject within the same scene as the object executing this callback that has that name.

 

datatype

The datatype tells the callback which data type it should be extracting from the UIObject. Note that regardless of what the original data type is, the data type that gets stored in the GUI Variable at the end will always be a string.

 

The data type values are:

bool -'true' or 'false' are the strings that will get stored in the GUI variable

int

float

string

strref

objectid

 

Again, it's important to remember that no matter what the originating data type is, the result will be stored as a string variable within the GUI variable specified.

 

index

This is the index of the data to extract. If the index is invalid for the UIObject, a default value will get stored in the GUI variable (Either "" or "0" or "false" depending on what the originating data type was).

 

destinationvar

This can be a local:# or global:#. The type of the stored data will always be a string.

 

Example 1

Now for some real examples that will work.

 

The grid icons in the inventory grid have the following data imbedded in them:

OBJECT_ID(0) = The object currently displayed in that icon

OBJECT_ID(1) = The object that was dispalyed in that icon on the previous frame

int(0) = The stacksize for that object on the previous update frame

int(1) = Indicates if the item is identified or not

int(2) = Indicates if the item is usable or not

int(3) = Indicates if the item is ghosted or not

 

It would be possible for me to change the inventory screen to drop items if I double right click on them.

 

I would edit the 'InvPrototypeButton' inside of inventory.xml and add:

 

OnRightDoubleClick0=UIObject_Misc_ExtractData("self:","objectid",0,local:3)

OnRightDoubleClick1=UIObject_Misc_ExecuteServerScript("gui_dropitem",local:3)

 

When I right double click that item, the first callback will extract the Object ID of the item and place it in local:3 as a string that looks like: "32144" or whatever the object ID is.

 

Then the 2nd callback would execute, asking the server to fire off the "gui_dropitem" script, and it would pass the 32144 value in as a parameter to the script (Either as a string "32144" or an integer 32144, depending on what the parameter type the script is expecting).

 

Now I will be adding an IntToObject() script funciton that will make it possible to take that int parameter and turn it into an object parameter. At that point, you could use the DropItem action and have the player drop that object.

 

Note that in this example, I would've had to remove the OnRightClick call to the context menu for the item button or it would end up blocking the double right click (Due to the context menu popping up and blocking the second click).

 

Example 2

This example is a lot more complicated, I'll try to explain it clearly. :)

 

The spell buttons in the game usually have the following pieces of data:

int(0) = The spell ID that the button represents

int(1) = The multi-class index that can cast that spell

int(2) = Not used anymore, so nothing.

int(3) = The meta magic feat, if any

int(4) = Whether or not this is a spontanously cast spell

int(5) = Whether or not this is a domain spell

int(6) = Whether or not this is a cheat-command spell cast

 

The values for int(3), the meta magic feat, are:

1 = Empower

2 = Extend

4 = Maximize

8 = Quicken

16 = Silent

32 = Still

64 = Persistent

128 = Permanent

 

The warlock invocations are also meta-magic feats, as follows (Note, I'm not sure how many of these are actually in the game, I'm just going down the list of constants in the code):

256 = Draining Blast

512 = Eldritch Spear

1024 = Frightful Blast

2048 = Hideous Blow

4096 = Beshadowed Blast

8192 = Brimstone Blast

16384 = Eldritch Chain

32768 = Hellrime Blast

65536 = Bewitching Blast

13102 = Eldritch Cone

262144 = Noxious Blast

524288 = Vitrioloic Blast

1048576 = Eldritch Doom

2097152 = Utterdark Blast

 

Let's say I want to make my own custom Examine Spell command for the spells_known.xml listing of spells.

 

First off, let's add our own custom radial menu (Another new feature in 1.06).

 

In spells_known.xml, I would go to the SPELLPANE_PROTO pane and add a

OnRightClick=UIObject_OnRadial_DisplayCustomRadial("root-customspell")

 

root-customspell will be the name of a new root node that I would then add to the contextmenu.xml

 

For now, that root node will only have 1 sub node called: node-spellexamine

 

node-spellexamine will be the name of a new radial node that I would make with the following callbacks:

OnLeftClickExpanded0=UIObject_Misc_ExtractData("context:uiobject","int",0,local:5)

OnLeftClickExpanded1=UIObject_Misc_ExecuteServerScript("gui_spellexamine",local:5)

OnLeftClickCollapsed0=UIObject_Misc_ExtractData("context:uiobject","int",0,local:5)

OnLeftClickCollapsed1=UIObject_Misc_ExecuteServerScript("gui_spellexamine",local:5)

 

Now when I go into the game and bring up the Spells Known screen and right click on the spell icon for a spell in the list, I will get a context menu with 1 item called 'Examine'. Clicking on that will first call:

UIObject_Misc_ExtractData()

which will extract the spell ID from int(0) on the button I brought the context menu up on and place that ID in local:5

 

Then it will fire

UIObject_Misc_ExecuteServerScript()

and pass along the spell ID (As stored in local:5) as the parameter to the script: gui_spellexamine

 

From there I can do whatever I want with that data. :)

 

To recap, the new features mentioned in this article are:

UIObject_Misc_ExtractData()

 

and

 

UIObject_OnRadial_DisplayCustomRadial()

 

Feel free to ask any time you would like me to provide a detailed list of what data is imbedded in a given UI Object. Some you'll probably be able to figure out on your own via trial and error, but I'll be happy to look into any specific UI Object if you need.

1 Comment


Recommended Comments

CollDet

Posted

yeah, thank you Rich. since i am adding a "mana" bar into partybar.xml, i would like to know the attributes and the wrapped data of 3 objects from that file:

 

1 ) PARTY_BAR_SLOT-(i guess that would be the best place to start)

2 ) CHAR_BOX

3 ) PM_PORTRAIT

 

thank you.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...