Wananazo Posted June 19, 2022 Share Posted June 19, 2022 How could I put an object in motion per hour? For example, I want a door to have a time to open and close. For example, I want the door to close at 1:00 p.m. and open at 3:00 p.m.How could I put an object in motion per hour? For example, I want a door to have a time to open and close. For example, I want the door to close at 1:00 p.m. and open at 3:00 p.m.How could I put an object in motion per hour? For example, I want a door to have a time to open and close. For example, I want the door to close at 1:00 p.m. and open at 3:00 p.m.How could I put an object in motion per hour? For example, I want a door to have a time to open and close. For example, I want the door to close at 1:00 p.m. and open at 3:00 p.m.How could I put an object in motion per hour? For example, I want a door to have a time to open and close. For example, I want the door to close at 1:00 p.m. and open at 3:00 p.m. I already have the script to open and close doors but I would like to add the code to it so that it opens and closes at a specific time How could I put an object in motion per hour? For example, I want a door to have a time to open and close. For example, I want the door to close at 1:00 p.m. and open at 3:00 p.m. Link to comment
Moderators Vinyard Posted June 19, 2022 Moderators Share Posted June 19, 2022 Hi, I've moved your thread to the main scripting section as this is the right place to post scripting-related questions. The tutorials section is reserved for posting, well... tutorials with the scope of teaching others. 1 Link to comment
AngelAlpha Posted June 19, 2022 Share Posted June 19, 2022 7 hours ago, Wananazo said: How could I put an object in motion per hour? For example, I want a door to have a time to open and close. For example, I want the door to close at 1:00 p.m. and open at 3:00 p.m.How could I put an object in motion per hour? For example, I want a door to have a time to open and close. For example, I want the door to close at 1:00 p.m. and open at 3:00 p.m.How could I put an object in motion per hour? For example, I want a door to have a time to open and close. For example, I want the door to close at 1:00 p.m. and open at 3:00 p.m.How could I put an object in motion per hour? For example, I want a door to have a time to open and close. For example, I want the door to close at 1:00 p.m. and open at 3:00 p.m.How could I put an object in motion per hour? For example, I want a door to have a time to open and close. For example, I want the door to close at 1:00 p.m. and open at 3:00 p.m. I already have the script to open and close doors but I would like to add the code to it so that it opens and closes at a specific time How could I put an object in motion per hour? For example, I want a door to have a time to open and close. For example, I want the door to close at 1:00 p.m. and open at 3:00 p.m. Show your code pls Link to comment
Hydra Posted June 19, 2022 Share Posted June 19, 2022 you could achieve this with timestamp if i'm not wrong 1 Link to comment
Wananazo Posted June 19, 2022 Author Share Posted June 19, 2022 local myGate2 = createObject (2957, 386.48864746094,-1526.0137939453,32.323436737061 , 0, 0, 45) --gate 2 function openMyGate() moveObject ( myGate2, 3000, 386.48864746094,-1526.0137939453,35.323436737061 ) end addCommandHandler("*1abrir",openMyGate) -- change this command to open the door in a timer that opens automatically every so often, for example if the object opened it should remain open for one hour and if the object closed it should remain closed for one hour function movingMyGateBack() moveObject ( myGate2, 3000, 386.48864746094,-1526.0137939453,32.323436737061) end addCommandHandler("*1cerrar",movingMyGateBack) local myGate3 = createObject (2957, 394.81704711914,-1527.3861083984,32.330768585205 , 0, 0, 130) --gate 3 Link to comment
Wananazo Posted June 19, 2022 Author Share Posted June 19, 2022 12 hours ago, AngelAlpha said: Show your code pls local myGate2 = createObject (2957, 386.48864746094,-1526.0137939453,32.323436737061 , 0, 0, 45) --gate 2 function openMyGate() moveObject ( myGate2, 3000, 386.48864746094,-1526.0137939453,35.323436737061 ) end addCommandHandler("*1abrir",openMyGate) -- change this command to open the door in a timer that opens automatically every so often, for example if the object opened it should remain open for one hour and if the object closed it should remain closed for one hour function movingMyGateBack() moveObject ( myGate2, 3000, 386.48864746094,-1526.0137939453,32.323436737061) end addCommandHandler("*1cerrar",movingMyGateBack) local myGate3 = createObject (2957, 394.81704711914,-1527.3861083984,32.330768585205 , 0, 0, 130) --gate 3 Link to comment
Addlibs Posted June 20, 2022 Share Posted June 20, 2022 You could use getRealTime to get the current timestamp, calculate the seconds remaining until the next scheduled time point (which you can calculate with getTimestamp), and setTimer for the many milliseconds. Link to comment
AngelAlpha Posted June 21, 2022 Share Posted June 21, 2022 On 20/06/2022 at 02:18, Wananazo said: local myGate2 = createObject (2957, 386.48864746094,-1526.0137939453,32.323436737061 , 0, 0, 45) --gate 2 function openMyGate() moveObject ( myGate2, 3000, 386.48864746094,-1526.0137939453,35.323436737061 ) end addCommandHandler("*1abrir",openMyGate) -- change this command to open the door in a timer that opens automatically every so often, for example if the object opened it should remain open for one hour and if the object closed it should remain closed for one hour function movingMyGateBack() moveObject ( myGate2, 3000, 386.48864746094,-1526.0137939453,32.323436737061) end addCommandHandler("*1cerrar",movingMyGateBack) local myGate3 = createObject (2957, 394.81704711914,-1527.3861083984,32.330768585205 , 0, 0, 130) --gate 3 local myGate2 = createObject (2957, 386.48864746094,-1526.0137939453,32.323436737061 , 0, 0, 45) --gate 2 function openMyGate() moveObject ( myGate2, 3000, 386.48864746094,-1526.0137939453,35.323436737061 ) end addCommandHandler("*1abrir",openMyGate) function movingMyGateBack() moveObject ( myGate2, 3000, 386.48864746094,-1526.0137939453,32.323436737061) end addCommandHandler("*1cerrar",movingMyGateBack) setTimer(function() local time = getRealTime() if time.hour >= 1 and time.hour < 3 then movingMyGateBack() else openMyGate() end end, 10000, 0) 1 Link to comment
Wananazo Posted June 22, 2022 Author Share Posted June 22, 2022 I have a question and I'm sorry I don't understand English very well what did it do here I've turned it around and I can't understand if time.hour >= 1 and time.hour < 3 then --but this one I don't understand very well what it means to movingMyGateBack() movingMyGateBack() --I understand that this is the call of the object in the time function Link to comment
Hydra Posted June 22, 2022 Share Posted June 22, 2022 4 hours ago, Wananazo said: I have a question and I'm sorry I don't understand English very well what did it do here I've turned it around and I can't understand if time.hour >= 1 and time.hour < 3 then --but this one I don't understand very well what it means to movingMyGateBack() movingMyGateBack() --I understand that this is the call of the object in the time function time.hour >= 1 // Means if the real hour is equal or higher than 1 time.hour < 3 // Means if the real hour is lower than 3 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