Hi People.
I am using some functions and each function have a (local t = event.target), but i have a function that i need to use the target of other function, it is possible to do? [import]uid: 26056 topic_id: 23216 reply_id: 323216[/import]
Hi People.
I am using some functions and each function have a (local t = event.target), but i have a function that i need to use the target of other function, it is possible to do? [import]uid: 26056 topic_id: 23216 reply_id: 323216[/import]
Can you assign the target of another function to a different variable to make this simple?
Eg, rather than t use t2 (just an example) and then refer to t and t2 in the function as needed? [import]uid: 52491 topic_id: 23216 reply_id: 92953[/import]
Hi peach, i am using somer like it:
local one = function()
local t = event.target
--code...
end
addEventListener(...)
-- and now, on this function i need to use the target of the
--function one and if a do this code on the function two (again
--local t = event.target) it will detect the object that event
--listener refer for the function two, and i need the objects
--(targets) of the function one
local two = function()
local t = event.target
--code...
end
addEventListener(...)
Can you show me a really simple exemple? because i am not understading the part of “refer t and t2 in the function” 
Thanks [import]uid: 26056 topic_id: 23216 reply_id: 92989[/import]
You could pre-declare some variables at the top of the lua file which you could use to store each functions event.target.
For example…
--Declare two new variables here..
local funcOneTarget
local funcTwoTarget
local one = function()
local t = event.target
--Then set the variable we made here..
funcOneTarget = t
--code...
end
addEventListener(...)
local two = function()
local t = event.target
funcTwoTarget = t
--code...
end
addEventListener(...)
Then you should be able to access them outside the functions. Is that what you had in mind? [import]uid: 69826 topic_id: 23216 reply_id: 92992[/import]
Bare in mind a small detail though. On TandG’s example, if for example the “one” listener runs first, the target for the second listener is yet undefined. [import]uid: 61899 topic_id: 23216 reply_id: 92997[/import]
Thats a good point, i probably should have mentioned that. Thanks clueless. [import]uid: 69826 topic_id: 23216 reply_id: 93002[/import]
Wow, is really it that i need, works so great
Thanks a lot for the answers people
[import]uid: 26056 topic_id: 23216 reply_id: 93017[/import]