arbna.us Posted October 16, 2013 Share Posted October 16, 2013 العنوان واضح أبي شرح لعمل حلقات في lua لأني راح أحتاجها في فكرة مستقبلية Link to comment
#DRAGON!FIRE Posted October 16, 2013 Share Posted October 16, 2013 (edited) العنوان واضح أبي شرح لعمل حلقات في luaلأني راح أحتاجها في فكرة مستقبلية # ; تستخدمها عشان تجيب جدول واشياء ثانية , ادخل عليها بـ لوأ واقرأ عليها وبتفهم @ Ex addEventHandler( "onClientResourceStart", resourceRoot, function ( ) --- حدث يوم السكربت يشتغل for _,v in ipairs( getElementsByType( "gui-label", resourceRoot ) ) do --- resourceRoot نجلب جميع اللبلات حق السكربت فقط ليه بس السكربت ؟ لانه ضفنا هنا guiSetFont ( v, "default-bold-small" ) --- بعد ما جلبنا جميع اللبلات نحط لهم الخط end end ) Edited September 4, 2014 by Guest Link to comment
arbna.us Posted October 16, 2013 Author Share Posted October 16, 2013 طيب ممكن أعرف الساينكس حقها Link to comment
#DRAGON!FIRE Posted October 16, 2013 Share Posted October 16, 2013 طيب ممكن أعرف الساينكس حقها The for statement has two variants: the numeric for and the generic for.A numeric for has the following syntax: for var=exp1,exp2,exp3 do something endThat loop will execute something for each value of var from exp1 to exp2, using exp3 as the step to increment var. This third expression is optional; when absent, Lua assumes one as the step value. As typical examples of such loops, we have for i=1,f(x) do print(i) end for i=10,1,-1 do print(i) endThe for loop has some subtleties that you should learn in order to make good use of it. First, all three expressions are evaluated once, before the loop starts. For instance, in the first example, f(x) is called only once. Second, the control variable is a local variable automatically declared by the for statement and is visible only inside the loop. A typical mistake is to assume that the variable still exists after the loop ends: for i=1,10 do print(i) end max = i -- probably wrong! `i' here is globalIf you need the value of the control variable after the loop (usually when you break the loop), you must save this value into another variable: -- find a value in a list local found = nil for i=1,a.n do if a == value then found = i -- save value of `i' break end end print(found)Third, you should never change the value of the control variable: The effect of such changes is unpredictable. If you want to break a for loop before its normal termination, use break. http://www.lua.org/pil/4.3.4.html 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