DonPro Posted April 13, 2015 Posted April 13, 2015 Hi everyone, im about to start a big Project for a group on a server, and i wanna ask if it's posible to make many objects and make them ALL move in just one line like: Lets say this is the objects: -(971, 1672.09, 737.20, 13.39, 0, 0, 270) -(971, 1672.09, 737.20, 13.39, 0, 0, 270) -(971, 1672.09, 737.20, 13.39, 0, 0, 270) -(971, 1672.09, 737.20, 13.39, 0, 0, 270) -(971, 1672.09, 737.20, 13.39, 0, 0, 270) -(971, 1672.09, 737.20, 13.39, 0, 0, 270) BUT i want maby 100 or more/less objects on the poject and you would think how much work it would be if i have to capy and paste 3 lines to where it should move, and move back. so i wonder is it posible to connect all this objects to ONLY one line like: Lets say all the objects would move here: -moveObject(gate, 10000, 1672.09, 729.20, 13.39) Someone pleas help me, i realy wanna do this project and i realy hope someone could make a form to me that would be like that so i can finish the project!
Mr.unpredictable. Posted April 13, 2015 Posted April 13, 2015 Take a look at this example script, that's how i created my script long back change the names of the object to something like a1 a2 a3 addEventHandler( "onResourceStart", resourceRoot, function() setTimer(move1, 1000,1) end ) local a = { [1] = "a1", --------- object name [2] = "a2", [3] = "a3", [4] = "a4" } function move1() for e=1, 4 do for _,object in ipairs(getElementsByType("object")) do if (getElementData(object,"name") == a[e]) then local x,y,z = getElementPosition(object) moveObject(object,60000,x+500,y,z) ------------- speed and local xyz axsis end end end end
DonPro Posted April 13, 2015 Author Posted April 13, 2015 Take a look at this example script, that's how i created my script long backchange the names of the object to something like a1 a2 a3 addEventHandler( "onResourceStart", resourceRoot, function() setTimer(move1, 1000,1) end ) local a = { [1] = "a1", --------- object name [2] = "a2", [3] = "a3", [4] = "a4" } function move1() for e=1, 4 do for _,object in ipairs(getElementsByType("object")) do if (getElementData(object,"name") == a[e]) then local x,y,z = getElementPosition(object) moveObject(object,60000,x+500,y,z) ------------- speed and local xyz axsis end end end end Where do i put the Cordinats for all the object?
Mr.unpredictable. Posted April 13, 2015 Posted April 13, 2015 In your map file just set the name and id of the objects has a1 a2 a3
DonPro Posted April 13, 2015 Author Posted April 13, 2015 In your map file just set the name and id of the objects has a1 a2 a3 Ahh, but what i realy want here is a object i can trigger by Command, and it go to the position, and i have to trigger another command to let the objects go to the next position.
Mr.unpredictable. Posted April 13, 2015 Posted April 13, 2015 In your map file just set the name and id of the objects has a1 a2 a3 Ahh, but what i realy want here is a object i can trigger by Command, and it go to the position, and i have to trigger another command to let the objects go to the next position. you can use AddCommandHandler for that and if you want the objects to be created with the command then just create the object using createobject function instead creating it in .map file.
DonPro Posted April 13, 2015 Author Posted April 13, 2015 In your map file just set the name and id of the objects has a1 a2 a3 Ahh, but what i realy want here is a object i can trigger by Command, and it go to the position, and i have to trigger another command to let the objects go to the next position. you can use AddCommandHandler for that and if you want the objects to be created with the command then just create the object using createobject function instead creating it in .map file. Okey, thanks for the help bro
DonPro Posted April 14, 2015 Author Posted April 14, 2015 In your map file just set the name and id of the objects has a1 a2 a3 Ahh, but what i realy want here is a object i can trigger by Command, and it go to the position, and i have to trigger another command to let the objects go to the next position. you can use AddCommandHandler for that and if you want the objects to be created with the command then just create the object using createobject function instead creating it in .map file. do you know why its [Error Lua :1: Unexepted symbol near ')' ? there is more errors on it addEventHandler( "onResourceStart", resourceRoot, function(cmd)) if cmd == "Start" then end addCommandHandler("Start", moveGate) local createObject = { [1] = createObject(10794, -1514.599609375, 242, 7, 0, 0, 0) --------- object ID/Position [2] = createObject(9586, -1516.7998046875, 242, 17, 0, 0, 0) [3] = createObject(9584, -1465.400390625, 242, 26.200000762939, 0, 0) [4] = createObject(9698, -1453.91015625, 240.826171875, 29.079999923706, 0, 0, 0) } function move1() for e=1, 4 do for _,object in ipairs(getElementsByType("object")) do if (getElementData(object,"id") == a[e]) then local x,y,z = getElementPosition(object) moveObject(object,60000,-1289.1999511719,293.20001220703,7,0,0,46) ------------- speed and local xyz axsis end end end end
yesyesok Posted April 14, 2015 Posted April 14, 2015 I think you should use unpredictable's example and just add local a1 = create object.
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