summaryrefslogtreecommitdiff
path: root/gamemode/itemsystem/common.lua
blob: 5a47c24525cec24ef04d297f9c97a35e97064d08 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
--This file holds a bunch of common functions that happen in items. They're seperated out here so that they're easy to change if there's a bug somewhere.

--Freezes the player, creates the loading bar, and calls ondone when the timer is up.
function startProcessGeneric(player, string, time, ondone)
  if(player.InProcess) then
    self.Owner:SendMessage("You can't do that much at once!", 3, Color(255, 255, 255, 255))
    return
  end
  player.InProcess = true
  player:Freeze(true)
  player:MakeProcessBar( string, time, false )
  timer.Create( "process", time, 1, function()
    player:Freeze(false)
    player.InProcess = false
    player:StopProcessBar()
    ondone()
  end)
end

local function plant(player, planttype)
  print("Plant method called!")
end

function genericMakePlantable( tbl )
  local plant = function(player)
    plant(player,tbl.Name)
  end
  if(tbl.Actions == nil) then
    tbl.Actions = {}
  end
  tbl.Actions["Plant " .. tbl.Name] = plant
end