Lloyd Logan Posted January 15, 2013 Posted January 15, 2013 Hey, In alot of the community scripts and WIKI examples, There's a line "for k, v in ipairs" what does this mean? and string.byte, what does this mean? full : function startup() local file = xmlLoadFile("pns.xml") for k, v in ipairs(xmlNodeGetChildren(file)) do local pos = split(xmlNodeGetAttribute(v,"pos"),string.byte(",")) local marker = createMarker(pos[1],pos[2],pos[3],"cylinder") createBlipAttachedTo(marker,63,2,255,0,0,255,0,250) setElementData(marker,"pnsMarker",true) setGarageOpen(tonumber(xmlNodeGetAttribute(v,"garage")),true) end xmlUnloadFile(file) end addEventHandler("onResourceStart",getResourceRootElement(),startup) Thanks Lloyd If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
psydomin Posted January 15, 2013 Posted January 15, 2013 It is a loop through a table "for" every "k" (key/index) and ", v" (value) "in ipairs(tableName)" (valid k and v on the same row of the table tableName) "do" something Currently working as a paid scripter. Contact me for details.
Lloyd Logan Posted January 15, 2013 Author Posted January 15, 2013 It is a loop through a table"for" every "k" (key/index) and ", v" (value) "in ipairs(tableName)" (valid k and v on the same row of the table tableName) "do" something Ahh, may be a bit much but could you give me an example If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
psydomin Posted January 15, 2013 Posted January 15, 2013 table1 = { [1] = {"This is the first row"}, [2] = {"This is the second row"} } for k, v in ipairs(table1) do outputChatBox("This is the row's index: "..k..", and this is the value of that row: "..v ) end it should output on the chat box:" This is the row's index: 1, and this is the value of that row: This is the first row This is the row's index: 2, and this is the value of that row: This is the second row " Currently working as a paid scripter. Contact me for details.
Lloyd Logan Posted January 15, 2013 Author Posted January 15, 2013 table1 = { [1] = {"This is the first row"}, [2] = {"This is the second row"} } for k, v in ipairs(table1) do outputChatBox("This is the row's index: "..k..", and this is the value of that row: "..v ) end it should output on the chat box:" This is the row's index: 1, and this is the value of that row: This is the first row This is the row's index: 2, and this is the value of that row: This is the second row " Thank you very much! I understand this quite a bit more! If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
Castillo Posted January 15, 2013 Posted January 15, 2013 Maybe you already know this, but "k" and "v" can be anything, doesn't has to be these two letters. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
Lloyd Logan Posted January 15, 2013 Author Posted January 15, 2013 Maybe you already know this, but "k" and "v" can be anything, doesn't has to be these two letters. I didn't, Thanks! If you need an Intermediate scripter feel free to PM me as I will accept "almost" any job, STATUS: UNAVAILABLE SCOTLAND, my hometown, and the Home of GTA!
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