Lloyd Logan Posted January 12, 2014 Share Posted January 12, 2014 When someone enters a marker, you would use onMarkerHit(themarkertheyentered) But if I have many markers, how can I use this so that if they enter any of these markers, one event is triggered (onMarkerHit) Link to comment
xXMADEXx Posted January 12, 2014 Share Posted January 12, 2014 addEventHandler ( "onMarkerHit", root, function ( p ) -- code end ) Link to comment
csiguusz Posted January 12, 2014 Share Posted January 12, 2014 Create a dummy element with createElement and set this elemenet as parent of your markers with setElementParent. Then define your onMarkerHit event handler attached to the dummy element. Link to comment
Lloyd Logan Posted January 12, 2014 Author Share Posted January 12, 2014 Create a dummy element with createElement and set this elemenet as parent of your markers with setElementParent. Then define your onMarkerHit event handler attached to the dummy element. Dummy element has to be a real element, or can be made up? Link to comment
Lloyd Logan Posted January 12, 2014 Author Share Posted January 12, 2014 Create a dummy element with createElement and set this elemenet as parent of your markers with setElementParent. Then define your onMarkerHit event handler attached to the dummy element. Dummy element has to be a real element, or can be made up? EDIT: Nevermind, I understand now thanks! Link to comment
csiguusz Posted January 12, 2014 Share Posted January 12, 2014 Read the wiki page. What you make with that function won't be a real entity in the world, it will youst behave like an element. Eg.: local marker1, marker2 = createMarker ( ... ), createMarker ( ... ) local ele = createElement ( "markers" ) setElementParent ( marker1, ele ) setElementParent ( marker2, ele ) addEventHandler ( "onMarkerHit", ele, function () outputChatBox ( "hit" ) end ) Edit: Great! You are welcome. Link to comment
Lloyd Logan Posted January 12, 2014 Author Share Posted January 12, 2014 Read the wiki page. What you make with that function won't be a real entity in the world, it will youst behave like an element. Eg.: local marker1, marker2 = createMarker ( ... ), createMarker ( ... ) local ele = createElement ( "markers" ) setElementParent ( marker1, ele ) setElementParent ( marker2, ele ) addEventHandler ( "onMarkerHit", ele, function () outputChatBox ( "hit" ) end ) Edit: Great! You are welcome. I have quite a number of markers, is there any easier way of doing local marker1, marker2 = createMarker ( ... ), createMarker ( ... ) local ele = createElement ( "markers" ) setElementParent ( marker1, ele ) setElementParent ( marker2, ele ) Link to comment
csiguusz Posted January 13, 2014 Share Posted January 13, 2014 A loop? local markers = { createMarker ( ... ), createMarker ( ... ), createMarker ( ... ) } for i, v in ipairs ( markers ) do setElementParent ( v, ele ) end Link to comment
Lloyd Logan Posted January 13, 2014 Author Share Posted January 13, 2014 A loop? local markers = { createMarker ( ... ), createMarker ( ... ), createMarker ( ... ) } for i, v in ipairs ( markers ) do setElementParent ( v, ele ) end Thank you! A quick question, what does; for i, v in ipairs ( markers ) do mean? Link to comment
Castillo Posted January 13, 2014 Share Posted January 13, 2014 It's a loop. http://lua-users.org/wiki/ForTutorial Link to comment
Lloyd Logan Posted January 13, 2014 Author Share Posted January 13, 2014 It's a loop.http://lua-users.org/wiki/ForTutorial I'll check that out Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now