Monument Posted March 26, 2021 Share Posted March 26, 2021 Hello i want to create Objects But in an organized way maybe Creation = 10 X Change = 5 Y Change = 6 when Creation = 10 then Automatically Create 10 Objects When Create 10 Objects The difference between each Object 1 and Object 2 = ' 5 x ' And in Y ' 6 y ' Thanks ! Link to comment
Haxardous Posted March 26, 2021 Share Posted March 26, 2021 are you trying to do a "for" loop? checkout this page: https://www.tutorialspoint.com/lua/lua_for_loop.htm 1 Link to comment
Monument Posted March 26, 2021 Author Share Posted March 26, 2021 17 minutes ago, Haxardous said: are you trying to do a "for" loop? checkout this page: https://www.tutorialspoint.com/lua/lua_for_loop.htm Yeah right, that's what I'm trying to do Also with some change of coordinates Link to comment
Moderators Patrick Posted March 26, 2021 Moderators Share Posted March 26, 2021 Something like: local creation = 10 local x_change = 5 local y_change = 6 local object_id = 955 local start_x, start_y, start_z = 0, 0, 3 for i = 1, creation do createObject(object_id, start_x + i*x_change, start_y + i*y_change, start_z) end Link to comment
Monument Posted March 26, 2021 Author Share Posted March 26, 2021 9 minutes ago, Patrick said: Something like: local creation = 10 local x_change = 5 local y_change = 6 local object_id = 955 local start_x, start_y, start_z = 0, 0, 3 for i = 1, creation do createObject(object_id, start_x + i*x_change, start_y + i*y_change, start_z) end thx its work good can i make name for it ? maybe object and it number Link to comment
Moderators Patrick Posted March 26, 2021 Moderators Share Posted March 26, 2021 5 hours ago, Monument said: thx its work good can i make name for it ? maybe object and it number I don't understand. Link to comment
Monument Posted March 27, 2021 Author Share Posted March 27, 2021 9 hours ago, Patrick said: I don't understand. the script make 10 object right ? for example i want getElementPosition to object number 2 but i can't because the element without name i try to do that Object[i] = createObject(..................) -- i = number from 1 to 10 In the example above getElementPosition(Object[2]) Link to comment
Moderators Patrick Posted March 27, 2021 Moderators Share Posted March 27, 2021 5 hours ago, Monument said: the script make 10 object right ? for example i want getElementPosition to object number 2 but i can't because the element without name i try to do that Object[i] = createObject(..................) -- i = number from 1 to 10 In the example above getElementPosition(Object[2]) local creation = 10 local x_change = 5 local y_change = 6 local object_id = 955 local start_x, start_y, start_z = 0, 0, 3 local objects = {} for i = 1, creation do objects[i] = createObject(object_id, start_x + i*x_change, start_y + i*y_change, start_z) end function getPositionOf(index) return (index and objects[index]) and getElementPosition(objects[index]) or false end local x, y, z = getPositionOf(2) iprint(x, y, z) Here are some excellent resources to learn the basics of Lua scripting: - https://wiki.multitheftauto.com/wiki/Main_Page - https://wiki.multitheftauto.com/wiki/Scripting_Introduction - https://www.lua.org/manual/5.1/ - https://wiki.multitheftauto.com/wiki/Category:Tutorials - https://forum.multitheftauto.com/topic/34453-manuals - https://forum.multitheftauto.com/topic/64228-the-ultimate-lua-tutorial/ - https://forum.multitheftauto.com/topic/121619-lua-for-absolute-beginners - https://forum.multitheftauto.com/topic/95654-tut-debugging/ - https://forum.multitheftauto.com/topic/114541-tut-events/ - https://forum.multitheftauto.com/topic/117472-tut-scaling-dx/ Videos: https://www.youtube.com/watch?v=Goqj5knKLQM&list=PLY2OlbN3OoCgTGO7kzQfIKPj4tJbYOgSR 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