kieran Posted June 14, 2017 Share Posted June 14, 2017 (edited) 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! Edited June 14, 2017 by kieran Tried attaching marker to the keypad using attach elements, but it then ignored moveObject function. Link to comment
Tourettes Posted June 15, 2017 Share Posted June 15, 2017 AttachElements attachElements ( marker_, KeyPad_, 0, 0, 0 ) Something like above for the attach maybe?... (untested) Link to comment
kieran Posted June 15, 2017 Author Share Posted June 15, 2017 10 hours ago, Tourettes said: AttachElements attachElements ( marker_, KeyPad_, 0, 0, 0 ) Something like above for the attach maybe?... (untested) Thanks, but I have tried this already, both elements stay in the same position and ignore rotation, I don't think there is a way to attach and move on marker hit... 1 Link to comment
kieran Posted June 15, 2017 Author Share Posted June 15, 2017 @Tourettes Remaining question.... How to set timers between/before a function? Link to comment
pa3ck Posted June 16, 2017 Share Posted June 16, 2017 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 2 Link to comment
kieran Posted June 16, 2017 Author Share Posted June 16, 2017 @pa3ckCheers! I thought it was something like this, but was unsure. 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