newUI.FindChildTraverse("Ability0").style.width = "43px";
newUI.FindChildTraverse("Ability0").style.height = "74px";
newUI.FindChildTraverse("Ability1").style.width = "43px";
newUI.FindChildTraverse("Ability1").style.height = "74px";```
I changed the size of the abilities of the heroes through the panorama, but after restart all reset and the size becomes default, to make my settings worked need to change something in the file (as I understand the file is recompiled). Is it possible to recompile the file with the settings at each start of the map or maybe there is another way to change the size of abilities, so that the settings are not reset every time?
#Resetting panorama settings after restart
1 messages · Page 1 of 1 (latest)
Recompiling just means that the file is converted into a language readable by the game. Once it is converted, it doesn't need to recompile.
So your problem has to do with something else.
How are you executing this code?
Do you get any errors when you restart?
I realized what the problem is. The problem is that abilities are resized before the ability panel is even displayed. But when I set a delay of 5 seconds before the function is executed, then the abilities resized.
But I realize it won't always work the way it should, is it possible to make a check in javascript to see if the hero is spawned or not?
You can have the server listen to npc spawned event, check if npc that was spawned is a hero, then send an event to panorama to do the scaling
JS:
{
newUI.FindChildTraverse("Ability4").style.width = "43px";
newUI.FindChildTraverse("Ability4").style.height = "74px";
newUI.FindChildTraverse("Ability4").style["margin-bottom"] = "12px";
newUI.FindChildTraverse("Ability4").style["margin-left"] = "6px";
newUI.FindChildTraverse("Ability5").style.width = "43px";
newUI.FindChildTraverse("Ability5").style.height = "74px";
newUI.FindChildTraverse("Ability5").style["margin-bottom"] = "12px";
}
GameEvents.Subscribe("skills_appear", Skills)```
Lua:
```if hero then CustomGameEventManager:Send_ServerToAllClients("skills_appear", {})
end```
This is the error I'm getting
Okay, so if I understand correctly, what you're seeing here is a hero that was spawned, but not yet selected. So it tries to find the newUI.FindChildTraverse("Ability4"), but failed - which results in undefined/null. Then you try to do undefined.style which is what the error is showing
That means that it's not a good option. Maybe you should listen to "unit select" events instead?
Its the IsHeroSelected function ?
You can listen to those events
Honestly, I didn't realize where I should write this, I'm just making a mod for dota in javascript and lua and am not familiar with typescript
You can write the exact same code as I did and be fine. You just remove the types. Typescript is Javascript with types.
For example the marked lines are not Typescript at all, they look exactly the same in JS
{
newUI.FindChildTraverse("Ability4").style.width = "43px";
newUI.FindChildTraverse("Ability4").style.height = "74px";
newUI.FindChildTraverse("Ability4").style["margin-bottom"] = "12px";
newUI.FindChildTraverse("Ability4").style["margin-left"] = "6px";
newUI.FindChildTraverse("Ability5").style.width = "43px";
newUI.FindChildTraverse("Ability5").style.height = "74px";
newUI.FindChildTraverse("Ability5").style["margin-bottom"] = "12px";
}
GameEvents.Subscribe("skills_appear", () => this.OnPlayerUpdateQueryUnit());
GameEvents.Subscribe("skills_appear", () => this.OnPlayerUpdateSelectedUnit());```
First, I meant that you should use the dota_player_update_query_unit and dota_player_update_selected_unit events, which are triggered when you select units. Not your skills_appear event, since it clearly doesn't work.
Second, If you don't have a function called OnPlayerUpdateQueryUnit in your code, then what is OnPlayerUpdateQueryUnit() supposed to do - it's just plain programming here.
Instead, you should change it to () => Skills() so it calls the Skills function that you do have.
Like this? GameEvents.Subscribe("dota_player_update_selected_unit", () => Skills());
I get the very first error.
Yeah. So seems like you'll have to debug when exactly this event is being triggered, and then check which elements are shown in the UI
You're specifically looking for "Ability4" and "Ability5", maybe those aren't always there?
I would change it to be something like
const ability4 = newUI.FindChildTraverse("Ability4");
if (ability4) {
ability4.style.width = "43px";
ability4.style.height = "74px";
ability4.style["margin-bottom"] = "12px";
ability4.style["margin-left"] = "6px";
}
basically - if it can find the Ability4 UI element - then you act on it, otherwise you skip it
maybe do a loop until it resizes?
you're assuming that you'll eventually find the UI element, which might not be the case. And then what, you'll just loop for eternity?
No, I'll get out of the loop
Sure. Try that.
Dota crashes on startup. Is there any way to put some kind of delay in the loop? i just started using javascript because of panorama.
In general, it would be easier for me to bind it to some event in lua, for example, when a player selects a unit
and also, when the panorama script is applied, all units on the map "get" 2 of my resized skills, but when I click on them, they are applied on my character
event in lua, for example, when a player selects a unit
But it can't be done. Think about it - in lua you are writing server code. The server doesn't know, and doesn't care, about what the players are looking at and which UI is shown to them. It only handles game logic.
This needs to be done in panorama, hence JS. JS and lua are pretty similar.
Dota crashes on startup
Probably because you're doing an infinite loop.
Is there any way to put some kind of delay in the loop
Yes, you can make a delay in each loop by using$.Scheduleto wait before executing the code. This would look like this:
myFunction() {
// do stuff
$.Schedule(1, () => myFunction();
}
myFunction();
which would mean the function calls itself after 1 second in each iteration - or basically, will loop forever, once per second.
Do I understand correctly that even if I make a delay after the start of the game to change the size of abilities, then if suddenly the player reconnects, for him, abilities will reset their size to default?
Yes, it resets. But the player will execute the panorama code again, as if it was loaded the first time
Do you know when this panorama code is executed? I set a delay of 5 seconds, on my computer it works, but will it work on others?
As soon as the client's game is loaded
but for some reason without delay the panorama executed too early and the size of abilities did not change
how do you know that the panorama is executed too early?
if I just call my function Skill() nothing happens, but if I write like this $.Schedule(5, Skill); it works.
What do you mean by nothing happens, is the JS throwing an error?
OK, so it sounds like it is finding the UI element and changing the UI, but it gets resized because the client is still loading the UI for the first time - that would be my guess
So probably some delay (like 5 seconds) is probably good to make sure everything is loaded before you override it
Yea, thanks for the help, but I still don't understand what it is 😂
All I know is that its definitely a problem on the panorama side.
I assume most units don't have "Ability4" and "Ability5" - and so they are hidden by having their size being seto to 0px - but you overrode that and gave those proper sizes.
Do you wish to always shrink ability4 and 5 of units that have it?
Or is it just a specific unit?
it would be good to return the total number of abilities a hero has and resize the last two
But assuming that all heroes in my game will only have 4 abilities, it won't be required, but I haven't decided yet
Alright, so what I would do is:
-
On client initialization, get the style and margin of an ability and save it to a variable so you can "reset" when necessary.
-
Find how many abilities the current selected unit has, make up to two abilities smaller, starting from the furthest abilities. Save the amount of abilities the unit has into a variable.
-
Listen to
dota_player_update_query_unitanddota_player_update_selected_unitevents -
Each time any of those events trigger, check how many abilities the current unit has. Then:
- If it has less abilities than the one before it (that was saved), then the left-over abilities need to be hidden, and the two furthest that do exist shrinked.
- If they have the same amount of abilities, (probably) nothing needs to be done.
- If they have more abilities, then they probably need to be reset to their original sizes and then the furhest need to be shrinked.
weird formatting issues in Discord, but you get the idea
Anyway, seems like a lot of testing is required, with trial an error fixing the issues little by little till you get it working like you want
Thank you so much, I'll keep trying!
Hi, could you tell me how to pass information about the number of abilities of a selected unit through the dota_player_update_query_unit and dota_player_update_selected_unit events?
that's all I get in the console, no matter what information I pass in:
You can check my code in the reply.
Basically, you get the local unit, and then you know most of everything about it