Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- OBJ_NAME = "Powerup Printer"
- PRINT_OBJECT_GUID = "cbbdeb"
- PRINT_TIME = 600
- TIMER_IDENTIFIER = nil
- timeToNextPrint = PRINT_TIME
- printedObject = false
- active = false
- function ToggleBool(obj, col)
- self.setDescription( self.getDescription()=="Locked" and "Unlocked" or "Locked" )
- self.editButton( {index=0, label=self.getDescription()} )
- if self.getDescription()=="Locked" then
- self.lock() else self.unlock()
- end
- end
- function onLoad()
- self.createButton({
- label="FIX THIS LATER", click_function="ToggleBool", function_owner=self,
- position={0,3,0}, rotation={0,0,0}, scale={2,2,2}, width=500, height=250, font_size=100
- })
- self.createButton({
- label="PRINT", click_function="printPowerUp", function_owner=self,
- position={2,1,2}, rotation={0,0,0}, scale={2,2,2}, width=500, height=250, font_size=100
- })
- if OBJ_NAME == nil then
- OBJ_NAME = self.getName()
- else
- self.setName(OBJ_NAME)
- end
- end
- --function onPickedUp(obj, player_clicker_color, alt_click)
- function printPowerUp(obj, player_clicker_color, alt_click)
- if not active and player_clicker_color ~= "Black" then
- activateTimer()
- active = true
- end
- end
- function activateTimer()
- local timerIdentifier = "Timer." .. math.random(1,10000)
- local timerFunction = "timerFire"
- local timerPassParams = {""}
- local timerDelay = 1
- local timerReps = 0
- local timerParams = {}
- timerParams.identifier = timerIdentifier
- timerParams.function_name = timerFunction
- timerParams.parameters = timerPassParams
- timerParams.delay = timerDelay
- timerParams.repetitions = timerReps
- Timer.create(timerParams)
- TIMER_IDENTIFIER = timerIdentifier
- end
- function onDestroy()
- if TIMER_IDENTIFIER then
- Timer.destroy(TIMER_IDENTIFIER)
- end
- end
- function printObject(objGUID)
- local objToClone = getObjectFromGUID(objGUID)
- local pos = self.getPosition()
- local yOffset = 1
- local cloneParams = {}
- cloneParams.position = {pos.x, pos.y + yOffset, pos.z}
- local clonedObj = objToClone.clone(cloneParams)
- clonedObj.unlock()
- end
- function timerFire()
- timeToNextPrint = timeToNextPrint - 1
- if timeToNextPrint <= 0 then
- printObject(PRINT_OBJECT_GUID)
- timeToNextPrint = PRINT_TIME
- end
- local timeLeft = string.format("%02d:%02d", timeToNextPrint / 60 % 60, timeToNextPrint % 60)
- self.setName(OBJ_NAME .. " (Next Print: " .. timeLeft .. ")")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement