Jump to content

[Question] moveObject timers/attach moving markers


kieran

Recommended Posts

Having some problems with an Elevator/lift script I am making, it's all on the comments below, but will write under too. :) 

--lift test
crate = createObject(2669, 2340.3000488281, 1544.9000244141, 11.10000038147, 0, 0, 90)--Creates the lift. 
crate_Rdoor = createObject(2678, 2342.8999023438, 1544.0999755859, 10.970000267029)
crate_Ldoor = createObject(2679, 2342.8999023438, 1545.6999511719, 10.970000267029, 0, 0, 180)
marker_ = createMarker(2338, 1546.1999511719, 11.10000038147, "arrow", 1, 100, 0, 0, 110)--Marker
KeyPad_ = createObject(2922, 2338, 1546.3000488281, 11.199999809265, 0, 0, 180)--Want to attach my marker to move with this.

--Function to close doors will be added here later.

(setTimer, 2000)	--Want to start the function AFTER the player hits the marker.

function crate_up(player) --Moves everything but marker up by 10)

	moveObject(crate, 10000, 2340.3000488281, 1544.9000244141, 21.10000038147)
	moveObject(crate_lift_Rdoor, 10000, 2342.8999023438, 1544.0999755859, 20.970000267029)
	moveObject(crate_lift_Ldoor, 10000, 2342.8999023438, 1545.6999511719, 20.970000267029)
	moveObject(KeyPad_, 10000, 2338, 1546.3000488281, 21.199999809265)
end

addEventHandler("onMarkerHit",marker_,crate_up)


--Another timer for doors opening at top will go here.

--Function to open doors will be added later.

--Final timer to move the crate back down (and marker).

function crate_down(player)

	moveObject(crate, 10000, 2340.3000488281, 1544.9000244141, 11.10000038147)
	moveObject(crate_Rdoor, 10000, 2342.8999023438, 1544.0999755859, 10.970000267029)
	moveObject(crate_Ldoor, 10000, 2342.8999023438, 1545.6999511719, 10.970000267029)
	moveObject(KeyPad_, 10000, 2338, 1546.3000488281, 11.199999809265)
end

addEventHandler("onMarkerLeave",marker_,crate_down)

Basically I want my marker attached to my keypad so the marker moves WITH the object.

I also want to set timers starting from marker hit, I am trying to hit marker, close doors, set timer for lift to move, then after that I can figure it out. (Will be using more than one timer.)

 

Thanks for any help/advice you have! :D 

Edited by kieran
Tried attaching marker to the keypad using attach elements, but it then ignored moveObject function.
Link to comment

If you look at setTimer on the wiki, you will understand, but to give you an idea

local myTimer = setTimer( function(text)
  outputChatBox("Timer after 5 seconds: " .. text)
end, 5000, 1, "myParam1")
  
function myFunctionName(text)
  outputChatBox("Timer after 5 seconds: " .. text)
end
local myTimer = setTimer( myFunctionName, 5000, 1, "myParam1")
  
-- function() ... end -> anonymous function
-- myFunctionName -> if you already have a function you will call
-- 5000 -> when should the timer start in ms, so 5000 = 5 seconds
-- 1 -> how many times the timer should run, every 5 seconds | 0 = infinite
-- myParam1 -> parameters you will pass to the function

 

  • Like 2
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...