SHARE
TWEET

Untitled

a guest Apr 19th, 2019 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. OBJ_NAME = "Powerup Printer"
  2. PRINT_OBJECT_GUID = "cbbdeb"
  3.  
  4. PRINT_TIME = 600
  5. TIMER_IDENTIFIER = nil
  6.  
  7. timeToNextPrint = PRINT_TIME
  8. printedObject = false
  9.  
  10. active = false
  11.  
  12. function ToggleBool(obj, col)
  13.  
  14.     self.setDescription( self.getDescription()=="Locked" and "Unlocked" or "Locked"  )
  15.  
  16.     self.editButton( {index=0, label=self.getDescription()} )
  17.     if self.getDescription()=="Locked" then
  18.         self.lock() else self.unlock()
  19.     end
  20.  
  21.  
  22. end
  23.  
  24.  
  25. function onLoad()
  26.  
  27.     self.createButton({
  28.         label="FIX THIS LATER", click_function="ToggleBool", function_owner=self,
  29.         position={0,3,0}, rotation={0,0,0}, scale={2,2,2}, width=500, height=250, font_size=100
  30.     })
  31.     self.createButton({
  32.         label="PRINT", click_function="printPowerUp", function_owner=self,
  33.         position={2,1,2}, rotation={0,0,0}, scale={2,2,2}, width=500, height=250, font_size=100
  34.     })
  35.  
  36.  
  37.     if OBJ_NAME == nil then
  38.         OBJ_NAME = self.getName()
  39.     else
  40.         self.setName(OBJ_NAME)
  41.     end
  42.  
  43. end
  44.  
  45. --function onPickedUp(obj, player_clicker_color, alt_click)
  46.  function printPowerUp(obj, player_clicker_color, alt_click)
  47.     if not active and player_clicker_color ~= "Black" then
  48.  
  49.         activateTimer()
  50.         active = true
  51.  
  52.     end
  53.  
  54. end
  55.  
  56. function activateTimer()
  57.  
  58.     local timerIdentifier = "Timer." .. math.random(1,10000)
  59.     local timerFunction = "timerFire"
  60.     local timerPassParams = {""}
  61.     local timerDelay = 1
  62.     local timerReps = 0
  63.  
  64.     local timerParams = {}
  65.     timerParams.identifier = timerIdentifier
  66.     timerParams.function_name = timerFunction
  67.     timerParams.parameters = timerPassParams
  68.     timerParams.delay = timerDelay
  69.     timerParams.repetitions = timerReps
  70.     Timer.create(timerParams)
  71.  
  72.     TIMER_IDENTIFIER = timerIdentifier
  73.  
  74. end
  75.  
  76. function onDestroy()
  77.  
  78.     if TIMER_IDENTIFIER then
  79.         Timer.destroy(TIMER_IDENTIFIER)
  80.     end
  81.  
  82. end
  83.  
  84. function printObject(objGUID)
  85.  
  86.     local objToClone = getObjectFromGUID(objGUID)
  87.  
  88.     local pos = self.getPosition()
  89.     local yOffset = 1
  90.  
  91.     local cloneParams = {}
  92.     cloneParams.position = {pos.x, pos.y + yOffset, pos.z}
  93.  
  94.     local clonedObj = objToClone.clone(cloneParams)
  95.     clonedObj.unlock()
  96.  
  97. end
  98.  
  99. function timerFire()
  100.  
  101.     timeToNextPrint = timeToNextPrint - 1
  102.  
  103.     if timeToNextPrint <= 0 then
  104.  
  105.         printObject(PRINT_OBJECT_GUID)
  106.         timeToNextPrint = PRINT_TIME
  107.  
  108.     end
  109.  
  110.     local timeLeft = string.format("%02d:%02d",  timeToNextPrint / 60 % 60, timeToNextPrint % 60)
  111.  
  112.     self.setName(OBJ_NAME ..  " (Next Print: " .. timeLeft .. ")")
  113.  
  114. end
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top