[SCRIPT] Simulate of interactive environment
Posted: Thu May 28, 2015 9:24 am
Hello everyone.
Do you want that a room react to you?
Then I have a example for you
Have a look at the result in the video: >click me<
And now, how it works:
You will need the following:
In my example i placed the objects so:
(i removed the other objects like alcove on this picture)

And now copy this script in the script entity:
that's all, have fun.
st1nger
Do you want that a room react to you?
Then I have a example for you
Have a look at the result in the video: >click me<
And now, how it works:
You will need the following:
- create 1x script entity with name: ap_script -> insert the script below
- create 1x timer with name: ap_timer_1 -> timerInterval : 0.5 , check only currentLevelOnly, connectors: onActivate, ap_script, checkDoor
- create 4x catacomb_pillar_lantern_01 with name: pl_1 - pl_4 -> uncheck light + particle boxes in editor. check for correct facing.
- create 1x force_field with name: ffield_puzzle_1 -> initialState = deactivate
- create 1x dungeon_door_portcullis with name: ap_door_1 -> Pull Chain + initialState = Closed
- create 1x floor_trigger in front of ap_door_1 with name: ap_trigger_1 -> check only triggeredByParty box -> connector 1: onActivate, ap_timer_1, start. connector 2: onDeactivate, ap_timer_1, stop
In my example i placed the objects so:
(i removed the other objects like alcove on this picture)

And now copy this script in the script entity:
Code: Select all
ap_timer_1.timer:stop() --Stops the timer so that it does not loop
--print("'ap_timer_1' stopped") -- debug message
ap_door_1_Flag = 0
--print("set 'ap_door_1_Flag' to 0") -- debug message
function triggerLight()
--print("execute: 'triggerLight'") -- debug message
delayedCall(self.go.id, 0.4, "enableLight1")
delayedCall(self.go.id, 0.5, "disableLight1")
delayedCall(self.go.id, 0.7, "enableLight1")
delayedCall(self.go.id, 0.8, "disableLight1")
delayedCall(self.go.id, 1.0, "enableLight1")
delayedCall(self.go.id, 1.1, "disableLight1")
delayedCall(self.go.id, 1.2, "enableLight1")
delayedCall(self.go.id, 1.3, "disableLight1")
delayedCall(self.go.id, 1.4, "enableLight1")
delayedCall(self.go.id, 0.7, "enableLight2")
delayedCall(self.go.id, 0.8, "disableLight2")
delayedCall(self.go.id, 1.0, "enableLight2")
delayedCall(self.go.id, 1.1, "disableLight2")
delayedCall(self.go.id, 1.3, "enableLight2")
delayedCall(self.go.id, 1.4, "disableLight2")
delayedCall(self.go.id, 1.5, "enableLight2")
delayedCall(self.go.id, 1.6, "disableLight2")
delayedCall(self.go.id, 1.7, "enableLight2")
delayedCall(self.go.id, 1.0, "enableLight3")
delayedCall(self.go.id, 1.1, "disableLight3")
delayedCall(self.go.id, 1.3, "enableLight3")
delayedCall(self.go.id, 1.4, "disableLight3")
delayedCall(self.go.id, 1.6, "enableLight3")
delayedCall(self.go.id, 1.7, "disableLight3")
delayedCall(self.go.id, 1.8, "enableLight3")
delayedCall(self.go.id, 1.9, "disableLight3")
delayedCall(self.go.id, 2.0, "enableLight3")
delayedCall(self.go.id, 1.3, "enableLight4")
delayedCall(self.go.id, 1.4, "disableLight4")
delayedCall(self.go.id, 1.6, "enableLight4")
delayedCall(self.go.id, 1.7, "disableLight4")
delayedCall(self.go.id, 1.9, "enableLight4")
delayedCall(self.go.id, 2.0, "disableLight4")
delayedCall(self.go.id, 2.1, "enableLight4")
delayedCall(self.go.id, 2.2, "disableLight4")
delayedCall(self.go.id, 2.3, "enableLight4")
delayedCall(self.go.id, 2.4, "activateFField")
delayedCall(self.go.id, 2.45, "deactivateFField")
delayedCall(self.go.id, 2.5, "activateFField")
delayedCall(self.go.id, 2.75, "deactivateFField")
delayedCall(self.go.id, 3.0, "activateFField")
end
function enableLight1()
--print("execute: 'enableLight1'") -- debug message
pl_1.light:enable()
pl_1.particle:enable()
end
function disableLight1()
--print("execute: 'disableLight1'") -- debug message
pl_1.light:disable()
pl_1.particle:disable()
end
function enableLight2()
--print("execute: 'enableLight2'") -- debug message
pl_2.light:enable()
pl_2.particle:enable()
end
function disableLight2()
--print("execute: 'disableLight2'") -- debug message
pl_2.light:disable()
pl_2.particle:disable()
end
function enableLight3()
--print("execute: 'enableLight3'") -- debug message
pl_3.light:enable()
pl_3.particle:enable()
end
function disableLight3()
--print("execute: 'disableLight3'") -- debug message
pl_3.light:disable()
pl_3.particle:disable()
end
function enableLight4()
--print("execute: 'enableLight4'") -- debug message
pl_4.light:enable()
pl_4.particle:enable()
end
function disableLight4()
--print("execute: 'disableLight4'") -- debug message
pl_4.light:disable()
pl_4.particle:disable()
end
function activateFField()
--print("execute: 'activateFField'") -- debug message
ffield_puzzle_1.controller:activate()
end
function deactivateFField()
--print("execute: 'deactivateFField'") -- debug message
ffield_puzzle_1.controller:deactivate()
end
function checkDoor()
--print("execute: 'checkDoor'") -- debug message
if ap_door_1.door:isOpening() == true and ap_door_1_Flag == 0 then
triggerLight()
ap_door_1_Flag = 1
--print("Set 'ap_door_1_Flag' to '1'") -- debug message
ap_trigger_1.floortrigger:setTriggeredByParty(false)
--print("Set 'ap_trigger_1.floortrigger:setTriggeredByParty' to 'false'") -- debug message
ap_timer_1.timer:stop()
--print("stop 'ap_timer_1'") -- debug message
end
endst1nger