SHARE
TWEET

Untitled

tinyevil Jul 17th, 2019 96 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function forges.open(player, forge_id, time)
  2.     local working_forge = player.forge.working_forge       
  3.     if (not working_forge) or working_forge.id ~= forge_id then
  4.         error("trying to open invalid forge")
  5.     end
  6.    
  7.     if not model.forges.is_ready(player, forge_id, time) then
  8.         error("forge not ready")
  9.     end
  10.    
  11.     local overdue = model.forges.get_overdue(player, forge_id, time)
  12.    
  13.     model.stats.inc(player, "melt_" .. forge_id)
  14.    
  15.     local owned = player.forge.owned_forges[forge_id]
  16.     owned.melts = (owned.melts or 0) + 1
  17.    
  18.     local upgrade_level = working_forge.upgrade_level      
  19.     local bars = data.forges.get_produced_bars(forge_id, upgrade_level)
  20.    
  21.     local loot_id = model.resources.add_loot(player, "bars", bars)
  22.     local loot = {{type="bars", amount=bars, loot_id=loot_id}}
  23.    
  24.     analytics.send("Forge.Open", {
  25.         bars = bars,
  26.         forge = forge_id,
  27.         overdue_minutes = math.floor(overdue/60),
  28.         ad_boost_count = working_forge.boost_ad or 0
  29.     })
  30.    
  31.     player.forge.working_forge = nil
  32.    
  33.     return loot
  34. 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