Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AIO Handle executes twice #193

Open
budasnorbi opened this issue Aug 14, 2024 · 1 comment
Open

AIO Handle executes twice #193

budasnorbi opened this issue Aug 14, 2024 · 1 comment

Comments

@budasnorbi
Copy link

Whenever i called AIO.Handle("AIOExample", "print") from a client event handler my print function on the server side got called twice.
But the client side event handler only got triggered once.

I am on the latest version of https://github.com/liyunfan1223/azerothcore-wotlk/tree/Playerbot

test.mp4

Here is the lua code:
`
local AIO = AIO or require("AIO")

local handler = AIO.AddHandlers("AIOExample", {});

if AIO.AddAddon() then
function handler.print()
print("Hello from client")
end
else
-- Create the base frame.
FrameTest = CreateFrame("Frame", "FrameTest", UIParent, "UIPanelDialogTemplate")
local frame = FrameTest

-- Some basic method usage..
-- Read the wow addon widget API for what each function does:
-- http://wowwiki.wikia.com/Widget_API
frame:SetSize(200, 200)
frame:RegisterForDrag("LeftButton")
frame:SetPoint("CENTER")
frame:SetToplevel(true)
frame:SetClampedToScreen(true)
-- Enable dragging of frame
frame:SetMovable(true)
frame:EnableMouse(true)
frame:SetScript("OnDragStart", frame.StartMoving)
frame:SetScript("OnHide", frame.StopMovingOrSizing)
frame:SetScript("OnDragStop", frame.StopMovingOrSizing)

-- This enables saving of the position of the frame over reload of the UI or restarting game
AIO.SavePosition(frame)

-- Creating an input:
local input = CreateFrame("EditBox", "InputTest", frame, "InputBoxTemplate")
input:SetSize(100, 30)
input:SetAutoFocus(false)
input:SetPoint("CENTER", frame, "CENTER", 0, 50)
input:SetScript("OnEnterPressed", input.ClearFocus)
input:SetScript("OnEscapePressed", input.ClearFocus)

-- Creating a slider:
local slider = CreateFrame("Slider", "SlideTest", frame, "OptionsSliderTemplate")
slider:SetSize(100, 17)
slider:SetPoint("CENTER", frame, "CENTER", 0, -50)
slider:SetValueStep(0.5)
slider:SetMinMaxValues(0, 100)
slider:SetValue(50)
slider.tooltipText = 'This is the Tooltip hint'
_G[slider:GetName() .."Text"]:SetText(50)
slider:SetScript("OnValueChanged", function(self) _G[slider:GetName() .."Text"]:SetText(self:GetValue()) end)
_G[slider:GetName().."High"]:Hide()
_G[slider:GetName().."Low"]:Hide()
slider:Show()

-- Creating a child, a button:
local button = CreateFrame("Button", "ButtonTest", frame)
button:SetSize(100, 30)
button:SetPoint("CENTER", frame, "CENTER")
button:EnableMouse(true)
-- Small script to clear the focus from input on click
button:SetScript("OnMouseUp", function() input:ClearFocus() end)
-- Usually I use UIPanelButtonTemplate for buttons, but I wanted to show and test some custom color texture here:
local texture = button:CreateTexture("TextureTest")
texture:SetAllPoints(button)
texture:SetTexture(0.5, 1, 1, 0.5)
button:SetNormalTexture(texture)
-- Set the font, could use GameFontNormal template, but I wanted to create my own
local fontstring = button:CreateFontString("FontTest")
fontstring:SetFont("Fonts\\FRIZQT__.TTF", 11, "OUTLINE, MONOCHROME")
fontstring:SetShadowOffset(1, -1)
button:SetFontString(fontstring)
button:SetText("Test")

function OnClickButton(btn)
    AIO.Handle("AIOExample", "print")
end

button:SetScript("OnClick", OnClickButton)
print("client")

end
`

Tested on latest version of Trinity Core and it worked well.
image

@budasnorbi budasnorbi changed the title AIO Handle executed twice AIO Handle executes twice Aug 14, 2024
@Foereaper
Copy link

OnAddonMessage is probably incorrectly called twice (core side issue), or you have AIO.lua registered twice server side in different directories.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants