View Single Post
04/25/17, 11:51 PM   #4
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by Rahon View Post
Code:
ADDON_NAME = "Test" EVENT_MANAGER: RegisterForEvent(ADDON_NAME,EVENT_MOUNTED_STATE_CHANGED, IsOnMount()) -- d(IsMounted("player")) -- d(onMount) local function IsOnMount(event, onMount) if onMount == IsMounted("player") then d("Mounting") else d("Unmounting") end

I'm guessing that it has something to do with "IsOnMount()" not receiving and/or the EVENT_MANAGER not giving away its variables - in this case the EventID and the Boolean value.

This is my first experience in coding in lua, so im glad for any help I can get.

cheers
  1. Welcome here
  2. IsOnMount() is a call not a reference. You write simply InOnMount, no brackets.
  3. In Lua nothing is known before it is declared. Means that IsOnMount is nil at the moment EVENT_MANAGER is used. You have to move it below the function declaration.
  4. ADDON_NAME should not be global, use the local keyword

greets.
  Reply With Quote