nikitafloy Posted May 20, 2014 Share Posted May 20, 2014 In this function terminates before for, why? function facJob( hitElement, matchingDimension ) if isElementWithinMarker ( hitElement, source ) then local attachedElements = getAttachedElements ( hitElement ) if attachedElements then outputChatBox('0') -- output 0 and all. for _, ElementValue in ipairs ( attachedElements ) do outputDebugString ( '1' ) if getElementModel ( ElementValue ) == 3016 then break else vbjob ( source, hitElement ) break end end else outputChatBox('2') vbjob ( source, hitElement ) end end end Link to comment
harryh Posted May 20, 2014 Share Posted May 20, 2014 Probably because element are not attached at line 4, so as there is no else to the if statement it would just end Link to comment
nikitafloy Posted May 21, 2014 Author Share Posted May 21, 2014 Probably because element are not attached at line 4, so as there is no else to the if statement it would just end Sorry, I don't really understand you. What should i do? I know that the table is created with the elements, but there are no elements. Then would it be written debug 'bad argument', but here it is not. Link to comment
Chronic Posted May 21, 2014 Share Posted May 21, 2014 getAttachedElements will output a table with all the elements attached to it, however if there are no elements attached to it it will return a blank table. If there are no elements attached to hitElement then line 6 will loop through an empty table. Good luck Link to comment
nikitafloy Posted May 22, 2014 Author Share Posted May 22, 2014 getAttachedElements will output a table with all the elements attached to it, however if there are no elements attached to it it will return a blank table.If there are no elements attached to hitElement then line 6 will loop through an empty table. Good luck I want to know what returns this table? nil - does not work. This is my main question. thx if attachedElements == nil then Link to comment
tosfera Posted May 22, 2014 Share Posted May 22, 2014 use this if-statement to see if the table is empty; if ( next ( attachedElements ) == nil ) then Link to comment
nikitafloy Posted May 22, 2014 Author Share Posted May 22, 2014 use this if-statement to see if the table is empty; if ( next ( attachedElements ) == nil ) then thx, I already did that. In table 2 values. 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