Skip to content

Commit

Permalink
Tweaked item-trigger.
Browse files Browse the repository at this point in the history
  • Loading branch information
expwnent committed Jul 1, 2014
1 parent f58e659 commit f4c9480
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions scripts/modtools/item-trigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
local eventful = require 'plugins.eventful'
local utils = require 'utils'
eventful.enableEvent(eventful.eventType.UNIT_ATTACK,1) -- this event type is cheap, so checking every tick is fine
eventful.enableEvent(eventful.eventType.INVENTORY_CHANGE,1000) --this is expensive, but you'll still want to set it lower
--eventful.enableEvent(eventful.eventType.INVENTORY_CHANGE,1000) --this is expensive, but you'll still want to set it lower
eventful.enableEvent(eventful.eventType.INVENTORY_CHANGE,1)

itemTriggers = itemTriggers or {}
Expand Down Expand Up @@ -70,7 +70,6 @@ function handler(table)

for _,command in ipairs(itemTriggers[itemType] or {}) do
if command[table.mode] then
print('asdf')
fillTable(command,table)
processTrigger(command)
unfillTable(command,table)
Expand All @@ -79,7 +78,6 @@ function handler(table)

for _,command in ipairs(materialTriggers[itemMatStr] or {}) do
if command[table.mode] then
print('asdf')
fillTable(command,table)
processTrigger(command)
unfillTable(command,table)
Expand All @@ -91,7 +89,6 @@ function handler(table)
local contaminantStr = contaminantMat:getToken()
table.contaminantMat = contaminantMat
for _,command in ipairs(contaminantTriggers[contaminantStr] or {}) do
print('asdf')
fillTable(command,table)
processTrigger(command)
unfillTable(command,table)
Expand Down Expand Up @@ -150,11 +147,18 @@ if args.clear then
contaminantTriggers = {}
end

if args.checkEvery then
if not tonumber(args.checkEvery) then
if args.checkAttackEvery then
if not tonumber(args.checkAttackEvery) then
error('checkEvery must be a number')
end
eventful.enableEvent(eventful.eventType.INVENTORY_CHANGE,tonumber(args.checkEvery))
eventful.enableEvent(eventful.eventType.UNIT_ATTACK,tonumber(args.checkAttackEvery))
end

if args.checkInventoryEvery then
if not tonumber(args.checkInventoryEvery) then
error('checkEvery must be a number')
end
eventful.enableEvent(eventful.eventType.INVENTORY_CHANGE,tonumber(args.checkInventoryEvery))
end

if not args.command then
Expand Down

0 comments on commit f4c9480

Please sign in to comment.