#Display unit tooltip name on panorama

1 messages · Page 1 of 1 (latest)

magic spear
#

I managed to send unit and hero names from Lua to panorama with GetUnitName(), sending for example "npc_dota_hero_axe", but I need to transform that into text of just "Axe" or "Death Prophet" but I don't want to manually list every single possible unit or hero name on the panorama script.

Sorry if I'm not clear, I'm starting to learn about panorama now, I know pratically nothing and this multiple scripts interactions is frying my small Lua brain

Here is an example of one of my attempts:

$("#PlayerDropDown").FindChildTraverse("player1").text = vdata.nHeroName;

vdata.nHeroName have the GetUnitName(), like "npc_dota_hero_axe", but the console says it is a null value. I know it is a null value, it's not a text, I just dont know how to turn this into text. Setting a manual text shows it back on panorama, so FindChildTraverse is fine.

digital ginkgo
#

$.Localize(vdata.nHeroName) is probably what you want but it seems your vdata is null?

#

did you print vdata and vdata.nHeroName with $.Msg to see what is null exactly?

#

vdata.nHeroName should be a string if you didnt make a mistake somewhere

magic spear
#

after restarting the game it now shows "NPC_DOTA_HERO_AXE" on panorama, so i'm half way there, now I just it to show "Axe"

digital ginkgo
#
$("#PlayerDropDown").FindChildTraverse("player1").text = $.Localize(vdata.nHeroName);
``` ?
magic spear
#

is there a way for me send "Axe" from Lua? instead of finding it on panorama?

digital ginkgo
#

no, try $.Localize('#' + vdata.nHeroName)

magic spear
#

that works

#

but I found a new problem after some testing

digital ginkgo
#

I forgot why # is needed

magic spear
#

the heroes names are supposed to update when the heroes spawns

#

put only the selected row updates

#

thats problem just bad scripting

#

once I select another row, it goes back to P 1

#

and the hero name is gone

digital ginkgo
#

FindChildTraverse("player1") is referencing only to P1 so yea, bad scripting

magic spear
#

yes, but what I mean is it updates only the selected row. The row list is unaffected. When the game start and all heroes spawns, my script repeats the process for player2, player3 and etc. Except for player1, all the other players return null text on console. The list still shows P1 instead of Sven, if a change the row to P2 and back to P1, the Sven name is gone, just P1.

#

i though it would remain

magic spear
# magic spear

This list should be full of all heroes names. I'm testing this by making bots select heroes before the game starts

indigo sorrel
#

Can't tell you what's going wrong without seeing the code

magic spear
magic spear
# magic spear

Yes, I'm an IF guy only when I'm learning something knew XD. My custom game have one extra player

indigo sorrel
#

why do you have all that outside the for loop

#

also have you checked your bots player id's on lua server? they might be -1

magic spear
magic spear
#

Ok, so I'll fix the loop now, see what happens

indigo sorrel
magic spear
#

now that I think about it, the script I copied had no repetitions, just a lot of data

#

makes sense now

magic spear
# magic spear

the operation vdata.hPlayerID+1 is not really the operation I was expecting. It's doing this:

0+1=01
1+1=11
2+1=21

Classic

#

I changed I few things, I think it no longer undestands it as a number but text

#

Why can't java but as smart as lua, this sucks

#

I worked around it. I changed a lot of the script but there's one thing left to fix

indigo sorrel
magic spear
#

selecting a new player now change the name to the hero but:

#

the list still doesn't change

indigo sorrel
#

can you show your current code. and either a print of the data, or the code that sends the event

magic spear
#

Now that I undestand that string you said, I managed to take away the IFs

#

I'm using 2 new functions to give me two new variables for comparison, since I couldn't operate 1+1

#

I'm updating the names at real time, instead of when they spawn

#

The default text is first defined here, maybe I need a paralel way to change this

#

The result of the $.Msg on the console. They return the hero table and the selected hero just fine

indigo sorrel
#

so what is the result you are seeing currently

magic spear
#

I don't want the list to show:

P 1
P 2
P 3
...

But this:

Zeus
Kunkka
Dragon Knight
...

magic spear
#

Oh, here is my init function with the CustomNetTable

indigo sorrel
#

something like this is what i would write

function SetHeroDisplayName(data) {
    for (let playerID in data) {
        let heroName = data[playerID]
        let panelName = "player" + playerID
        $("#PlayerDropDown").FindChildTraverse(panelName).text = $.Localize("#" + heroName)
    }
}
#

well actually, you'd need to account for the panel id's being +1

#

since player id's start at 0

#

you'd be better off making the panel id's start at 0 instead though

#

and this code is assuming there as many panels as there are players.
you could make it better to add/remove panels to match the data

indigo sorrel
#

let me know if thats working for you

magic spear
#

I'm yet to properly learn how to add/remove panels in the script, but It sounds like it could fix my problem if its possible to define the text when adding them

indigo sorrel
#
let panelType = "Panel"
let panelParent = $("#somePanel")
let newPanel = $.CreatePanel(panelType, panelParent, "myPanelID")
#

for a label, you'd use "Label" instead of "Panel"
and then you could do:

newPanel.text = "some text"
#

to delete a panel you can use:

newPanel.RemoveAndDeleteChildren()
magic spear
#

It doesnt open

indigo sorrel
#

apparently for DropDown panels you'd also need to add them to the list.
panelParent.AddOption(newPanel)

magic spear
#

It works

#

I can finally take a break and come back to my lua stuff

#

thanks man, helped me a lot

#

Oh before I forgot

#

I have an inactive function that when activated it hides from the player screen

#

I did this so I could hide this panel from all players except for the extra player

#

So I can run this function in the init function for all players except the extra player?

#

I'll test it right now, along the way Ive never tested trying to solve the other problems

#

The extra player is on a custom team

#

custom team 1

magic spear
#

Also, after creating the labels there's no label selected by default. Can I force the selection of a label after creating them?

#

Like AddOption but SelectOption?

#

SelectOption doesn't exist XD

indigo sorrel
#

SetSelected

magic spear
#

Hello, I'm back

#

So I've been doing a lot of things, and now I want to dinamically $.Localize the added options on another function, but I'm struggling to "find" it. Something like "FindChildTraverse", but that don't work for options on a Dropdown

#

I want to find all added options and refresh the localize

indigo sorrel
#

panel.Children() would give you every child of that panel

magic spear
#

I made it return the children every time a new option is added

#

I'm cursed

#

so to remove an option is with removeOption, right?

#

well, actually I can't do that if I can't find the option

indigo sorrel
#

RemoveAllOptions is a thing

magic spear
#

Ok, I tried GetParent() right after creating an option

#

I got something

#

{"paneltype":"DropDownMenu","rememberchildfocus":false,"style":{},"actualuiscale_x":0.7111110687255859,"actualuiscale_y":0.7111110687255859,"scrolloffset_x":0,"scrolloffset_y":0,"actualyoffset":0,"actualxoffset":0,"actuallayoutheight":0,"actuallayoutwidth":0,"desiredlayoutheight":0,"desiredlayoutwidth":0,"contentheight":0,"contentwidth":0,"layoutfile":"panorama\layout\custom_game\hud_god_mode.xml","id":"PlayerDropDownDropDownMenu","type":"DropDownMenu","selectionpos_y":null,"selectionpos_x":null,"tabindex":null,"hittestchildren":true,"hittest":true,"inputnamespace":"","defaultfocus":"","checked":false,"enabled":true,"visible":true}

#

its huge

#

I know the parent is #PlayerDropDown, so is it "id" or "type"?

#

using RemoveAllOptions on #PlayerDrownDown truly removed all of them XD

#

so now my new function will remove all options and run again the first function

magic spear
#

I'm already updating the herolist with a CustomNetTable