MRmihailZH Posted January 22, 2020 Posted January 22, 2020 Here is the function that moves the object, I understand that instead of rotation -80, I need to write some formula that will determine how much it needs to lower / rise, but I can’t achieve such a result. Therefore, I ask for your help, thank you in advance. gateLSPD = false x, y, z = getElementPosition ( source ) if getDistanceBetweenPoints3D ( x, y, z, 1544.24707, -1631.90906, 13.38281 ) <= 2 then if gateLSPD == false then local rotX, rotY, rotZ = getElementRotation(shlagLSPD) moveObject ( shlagLSPD, 2000, 1544.6999511719, -1630.9000244141, 13.10000038147, 0, -80, 0 ) gateLSPD = true else local rotX, rotY, rotZ = getElementRotation(shlagLSPD) moveObject ( shlagLSPD, 2000, 1544.6999511719, -1630.9000244141, 13.10000038147, 0, 80, 0 ) gateLSPD = false end end
Moderators Patrick Posted January 22, 2020 Moderators Posted January 22, 2020 The simplest way if you limit the command usage. 1
MRmihailZH Posted January 23, 2020 Author Posted January 23, 2020 6 hours ago, stPatrick said: The simplest way if you limit the command usage. I understand this very well, but I do not want to limit it. Are there any other options?
Saml1er Posted January 24, 2020 Posted January 24, 2020 (edited) local gateCommandWaitInMs = 3000 -- 3000 milliseconds. You can increase or decrease this value to meet your requirements local objectMovingTick = getTickCount() + gateCommandWaitInMs -- we are adding this to tick, so we don't have to wait for 3 seconds in first use gateLSPD = false x, y, z = getElementPosition ( source ) if getDistanceBetweenPoints3D ( x, y, z, 1544.24707, -1631.90906, 13.38281 ) <= 2 then if (objectMovingTick - getTickCount()) < gateCommandWaitInMs then -- check if 3000 milliseconds have passed return end if gateLSPD == false then local rotX, rotY, rotZ = getElementRotation(shlagLSPD) moveObject ( shlagLSPD, 2000, 1544.6999511719, -1630.9000244141, 13.10000038147, 0, -80, 0 ) gateLSPD = true else local rotX, rotY, rotZ = getElementRotation(shlagLSPD) moveObject ( shlagLSPD, 2000, 1544.6999511719, -1630.9000244141, 13.10000038147, 0, 80, 0 ) gateLSPD = false end objectMovingTick = getTickCount() end You can use getTickCount to fix the problem. Edited January 24, 2020 by Saml1er
MRmihailZH Posted January 25, 2020 Author Posted January 25, 2020 On 24/01/2020 at 04:13, Saml1er said: local gateCommandWaitInMs = 3000 -- 3000 milliseconds. You can increase or decrease this value to meet your requirements local objectMovingTick = getTickCount() + gateCommandWaitInMs -- we are adding this to tick, so we don't have to wait for 3 seconds in first use gateLSPD = false x, y, z = getElementPosition ( source ) if getDistanceBetweenPoints3D ( x, y, z, 1544.24707, -1631.90906, 13.38281 ) <= 2 then if (objectMovingTick - getTickCount()) < gateCommandWaitInMs then -- check if 3000 milliseconds have passed return end if gateLSPD == false then local rotX, rotY, rotZ = getElementRotation(shlagLSPD) moveObject ( shlagLSPD, 2000, 1544.6999511719, -1630.9000244141, 13.10000038147, 0, -80, 0 ) gateLSPD = true else local rotX, rotY, rotZ = getElementRotation(shlagLSPD) moveObject ( shlagLSPD, 2000, 1544.6999511719, -1630.9000244141, 13.10000038147, 0, 80, 0 ) gateLSPD = false end objectMovingTick = getTickCount() end You can use getTickCount to fix the problem. I tried your code and nothing happens. I tried to fix something and also all to no avail.
Saml1er Posted January 26, 2020 Posted January 26, 2020 23 hours ago, MRmihailZH said: I tried your code and nothing happens. I tried to fix something and also all to no avail. if (objectMovingTick - getTickCount()) < gateCommandWaitInMs then I made a typo here. This should be: if (getTickCount() - objectMovingTick) < gateCommandWaitInMs then
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