Jump to content

How to create a system of doors that open by schedules


Recommended Posts

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
  • Scripting Moderators

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.

  • Like 1
Link to comment
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

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
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
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)

 

  • Thanks 1
Link to comment

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...