
local timeTot = 0
local timePerUpdate = 1
local Get = Object.GetProperty
local Set = Object.SetProperty

function getObject(type,id,dist)
	objs = Object.GetNearbyObjects(type,dist or 1)
	for o,d in pairs(objs) do
		 if o.Id.i == id then
		 	return o
		 end
	end
end

function Create()
	Set(this,"Tooltip", "tooltip_VendingOrangeJuicer")
end

function Update(timePassed)
	timeTot=timeTot+timePassed
	if timeTot > timePerUpdate then
		timeTot=0
		if tonumber(this.Slot0.i) > -1 then
			if oranges == nil then
				oranges = getObject("Stack",this.Slot0.i,2)
			else
				if Get(oranges,"Quantity") ~= nil and Get(oranges,"Quantity") % 2 == 0 then
					this.SubType = 1
				else
					this.SubType = 0
				end
			end
		else
			oranges = nil
		end 
	end
end
