Inverse switches when door is opened

Gent’s

I’ve tried to get a lamp blinking a couple of times as the door sensor is tripped.
Since I’m a newbee on LUA / Luup or whatever its called, I’ve copied some code on the net and changed it a bit for my purposes. (btw I’ve an Vera Plus).

For some reason it fails, please tell me why (it is included as part of a scene).
The most disturbing error is:
input:25: attempt to index a nil value (global ‘luup’)

How to address this fault?

It probably contains of a lot of syntax errors which are obvious to you, but I hope you get the idea with this code. I.e it shall notify me when I’m upstairs with a flashing light when someone is openening the door (which I usually can’t here from the top floor)

-------------------------------------------------------------------
local array_lights = {132} --using just one device to test for now
local original_status = {}
local current_status = {}
local delay = 1
local count = 0
local maxcount = 5
-------------------------------------------------------------------



local function inverse_switch(device,currentstate)
	if currentstate == "1" then
		luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue=0 }, device)
		return 0
	else
		luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ newTargetValue=1 }, device)
		return 1
	end
end


local function backup_status()
	for i, device in ipairs(array_lights) do
		original_status[i] = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1","Status", device)
		current_status[i] = original_status[i] 	
	end
end


local function restore_status()
	for i, device in ipairs(array_lights) do
		luup.call_action("urn:upnp-org:serviceId:SwitchPower1","SetTarget",{ device, original_status[i] }, device) 
	end
end

-------------------------------------------------------------------
--save original status
backup_status()

--Loop until max count is reached
while count < maxcount do
	for i, device in ipairs(array_lights) do
		current_status[i] = inverse_switch(device,current_status[i])
	end

	count = count + 1
end

--Restore original values
restore_status()

return true
-------------------------------------------------------------------