SecureHandlerState
I would like to create a state handler for the vehicle state when the player is in vehicle and has a vehicle UI.
I have tried: Lua Code:
However there are some issues with this one since there are some flight masters which incorrectly returns invehicle, even when you are not in one. (Like the dragons in Dragon Soul and in some other instances.) I have also tried this one, which works better, however it also returns invehicle when the user has no vehicle ui. Lua Code:
If someone could help me merge the two methods somehow, or if someone has a proper state driver for this i would be greatful. |
[vehicleui]
10charshello |
Quote:
|
you can 'WrapScript' the 'OnShow' & 'OnHide' vehicule ui. more reliable than [vehicleui].
Code:
for i=1, 6 do |
Quote:
|
On a side note, you can use @player and @vehicle to specify the target of the condition rather than the old target= syntax. This option was implemented as a more intuitive way to define the target of a condition since people were trying to use the old syntax for checking if your target was a specified unit.
|
Quote:
When the player have a pet summoned and have a pet frame, then i switch the pet frame to the player frame when the UNIT_ENTERED_VEHICLE gets triggeted with a vehicle ui. However sometimes from UNIT_ENTERING_VEHICLE to UNIT_ENTERED_VEHICLE and from UNIT_EXITING_VEHICLE to UNIT_EXITED_VEHICLE, the pet frame instead of showing the player or the pet shows the vehicle frame for a second for no reason. I'm not sure how to dodge that securely. I wrote a workaround to unregisted and reregister the pet frame between this events, but thats not gonna work in combat: Lua Code:
|
Quote:
this is the script i use for the pet action bar : RegisterStateDriver(myframe, "visibility", "[target=pet,exists, novehicleui, nopossessbar] show; hide;") hope it can help. you can also see in RestrictedEnvironment.lua there are functions about vehiculeui that you can use in the handler |
Quote:
Also, if you're using the SecureStateDriver system, they don't necessarily listen to these events and are delayed by at least 200ms. You might be able to hook into the OnAttributeChanged script to act on when RegisterUnitWatch() triggers. If you leave it to show/hide the frame itself, it changes the statehidden attribute to a true/nil value. At this point, I'm just running off a list of what could be going on. I don't see what self:UpdateDisplay() is doing or how unit switching is being handled not only from the artwork aspect, but how the SecureUnitButton template is being used. All that's being shown is debug code that isn't really going to work in the end product. |
Quote:
Lua Code:
By default i only use the *ED events but thats when the issue happens, thats why i added the *ING events to hide the frame between them. The UpdateDisplay() funtion is noting special just updates the frame, name level buffs etc. Also my SecureUnitButton has nothing special it's using the RegisterUnitWatch method. The whole code: https://github.com/Resike/Z-Perl2/bl.../PlayerPet.lua |
You can use RegisterAttributeDriver() to securely swap the unit of a SecureUnitFrame. Just use this to replace the entire self.frame.state block.
Code:
RegisterAttributeDriver(self.frame,"unit","[vehicleui] player; pet") Updating the frame when this happens can be done with an OnAttributeChanged script hook. Since I highly doubt you're doing anything protected in PlayerPet:UpdateDisplay(), you can just call that. Code:
self.frame:HookScript("OnAttributeChanged",function() PlayerPet:UpdateDisplay(); end) |
Quote:
|
It looks pretty cool now, however it's still a bit out of sync. Would it be possible to write a driver which gets triggered exactly at UNIT_ENTERED_VEHICLE and UNIT_EXITING_VEHICLE?
https://www.youtube.com/watch?v=QxNeWByv4b4 |
As far as I know, you can register the events yourself without tainting the secure driver system, but I'm not 100% sure.
Code:
SecureStateDriverManager:RegisterEvent("UNIT_ENTERED_VEHICLE"); |
Quote:
|
Just add those lines as-is to your code. It registers those events to the secure frame that manages RegisterAttributeDriver().
This frame is found in SecureStateDriver.lua. |
Quote:
The problem is that the vehicleui trigger gets triggered before those events so it pointless to scan the state again after. It would be nice to only scan on this two events. |
RegisterAttributeDriver() is just handling what unit is selected when you click on the frame and should handle RegisterUnitWatch() fine on its own. It's just a more direct approach to what you were already doing. The display code, you can do whatever you want and it isn't going to hurt the SecureUnitFrame. The problem is still located there. Try taking the code back to the basics and replace the 4 vehicle event blocks with this. Don't forget to unregister UNIT_ENTERING_VEHICLE and UNIT_EXITED_VEHICLE.
Lua Code:
|
Quote:
Here is a video about it: https://www.youtube.com/watch?v=IgjRxkEk5TM |
I figured i can dodge the entering issue if i unregister and reregister some events:
Lua Code:
Still not sure about what could be done with the exiting issue. |
All times are GMT -6. The time now is 12:12 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI