Sorry, not gonna try to put this into command script items, but what you want to do is:
1)
will give you an cursor to select (request) an target. That's the easy part.
2) To get the response (target) you have to register to the SystemData.Events.TARGET_SEND_ID_CLIENT event. This is accomplished by
Code:
WindowRegisterEventHandler("MyWindow", SystemData.Events.TARGET_SEND_ID_CLIENT, "MyWindow.RequestTargetInfoReceived")
3) Once you selected a target,
Code:
MyWindow.RequestTargetInfoReceived
will be called and you can use
Code:
SystemData.RequestInfo.ObjectId
to get the Id of the selected object (i.e. your pet)
4) To get from the id to the pet's name, you need to register windowdata for pets with
Code:
RegisterWindowData(WindowData.Pets.Type, 0)
and then you can loop through all pets to find the one you targeted:
Code:
if (WindowData.Pets.PetId ~= nil ) then
local petSize = table.getn(WindowData.Pets.PetId)
if (petSize > 0) then
for numPet = 1, petSize do
local mobileId = WindowData.Pets.PetId[numPet]
...
5) To persist between logouts, you can use
Code:
Interface.SaveString( settingName, settingValue )
to save the pets name and use LoadString to get it back. You can also store the id with StoreNumber/LoadNumber.
Ideally you want to have a window for 2) and 3) since you don't want to mess with other target cursors of other parts of the UI. You could quick n dirty register to "Root" instead of "MyWindow", but if you cancel a request or forget to unregister the response handler that might screw things up a bit.
If you not gonna put it into a mod, I doubt you gonna have fun with this
