View Single Post
09-02-15, 06:48 PM   #1
Nikita S. Doroshenko
A Cyclonian
 
Nikita S. Doroshenko's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2015
Posts: 45
Any way to fire function X(self) with self param. from function Y() without events?

I got frame with self.A = 1, self.B = 2 and so on... parameters.

In this frame i trigger function X(self) when PLAYER_ENTERING_WORLD.

Code:
<Frame>
	<Scripts>
		<OnLoad>
			self:RegisterEvent("PLAYER_ENTERING_WORLD")
			self.A = 1
			self.B = 2
		</OnLoad>
		<OnEvent>
			self:UnregisterEvent("PLAYER_ENTERING_WORLD")
			X(self)
		</OnEvent>
	</Scripts>
</Frame>
Lua Code:
  1. function X(self)
  2.     print(self.A, self.B...) -- output 1 and 2 and so on paraetrs...
  3. end

And i got function Y() that trigger when custom Button pressed.

Code:
<Button>
	<Scripts>
		<OnLoad>
			self.Z = true
		</OnLoad>
		<OnClick>
			Y()
		</OnClick>
	</Scripts>
</Button>
Lua Code:
  1. function Y()
  2.     if self.Z == true then
  3.         -- Then i want to trigger function X(self) with it's frame self.A = 1, self.B = 2... parameters
  4.     end
  5. end

What is want, is to trigger frame function X(self) with self.A = 1, self.B = 2 parameters with function Y() or after Button pressed.

Will appreciate your help.
  Reply With Quote