First time posting here, trying(albeit failing) to wrap my head around Lua. I'm trying to code a simple spike trap that would work off of a timer. The trap would activate spike traps in a pattern(Im thinking determined by a timer) however I can't get the darn traps to spring using a Script. Here's the test run I have below but obviously I fail at Lau language and cant get it to fire off. I have a timer connected to the script Lau. Im thinking im not defining what the floor_spike_trap is I.e. a trap but im not sure what its called or maybe im totally off base here. Anyway any help is much appreciated.
function Spikestrap()
if timecount == 1 then
floor_spike_trap_7:activate()
elseif timecount == 2 then
floor_spike_trap_8:activate()
end
timecount = 1
return
end
Spike Trap Script Help Needed
Re: Spike Trap Script Help Needed
floor_spike_trap_7.controller:activate()
is what youre looking for. Also i made a kind of basic spike-trap thingy here
is what youre looking for. Also i made a kind of basic spike-trap thingy here
Links to my YouTube playlist of "tutorials" and to my forum thread.
Re: Spike Trap Script Help Needed
When do you deactivate the traps ? With your example they will both be activated after 2 secs (timer ticks). Also: you're setting timecount to 1 every time the function runs (it's outside the elsif clause). If you want it to cycle you have to do something like that:
also: @Prozail - thinking about next video tutorial
?
Code: Select all
function Spikestrap()
if timecount == 1 then
floor_spike_trap_7.controller:activate()
floor_spike_trap_8.controller:deactivate()
elseif timecount == 2 then
floor_spike_trap_8.controller:activate()
floor_spike_trap_7.controller:deactivate()
timecount = 1
end
end
Last edited by Blichew on Fri Nov 07, 2014 11:04 am, edited 1 time in total.
Re: Spike Trap Script Help Needed
You don't need to deactivate them asfaik. Activate just does a one-shot.
Links to my YouTube playlist of "tutorials" and to my forum thread.
Re: Spike Trap Script Help Needed
Oh, then I've just added two useless lines to this code
still timecount has to be under elsif to alter between 1 and 2
Re: Spike Trap Script Help Needed
Doh controller! Thank you, when I get some time ill check it out. Thank you for the responses everyone.