Skip to content
This repository has been archived by the owner on Jul 1, 2020. It is now read-only.

Commit

Permalink
Fix on_step not iterating over gunslinger.__automatic properly
Browse files Browse the repository at this point in the history
Also eliminate delay when starting to fire automatic guns
  • Loading branch information
ClobberXD committed Mar 25, 2019
1 parent 8df1192 commit 61e18a5
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ local function on_lclick(stack, player)
gunslinger.__interval[name] = 0

if def.mode == "automatic" and not gunslinger.__automatic[name] then
stack = fire(stack, player)
add_auto(name, def, stack)
elseif def.mode == "hybrid"
and not gunslinger.__automatic[name] then
Expand Down Expand Up @@ -274,18 +275,18 @@ local function on_step(dtime)
gunslinger.__automatic[name] = nil
return
end
if gunslinger.__interval[name] < info.def.unit_time then
return
end
if player:get_player_control().LMB then
-- If LMB pressed, fire
info.stack = fire(info.stack, player)
player:set_wielded_item(info.stack)
gunslinger.__automatic[name].stack = info.stack
gunslinger.__interval[name] = 0
else
-- If LMB not pressed, remove player from list
gunslinger.__automatic[name] = nil
if gunslinger.__interval[name] > info.def.unit_time then
if player:get_player_control().LMB and
player:get_wielded_item():get_name() == info.stack:get_name() then
-- If LMB pressed, fire
info.stack = fire(info.stack, player)
player:set_wielded_item(info.stack)
gunslinger.__automatic[name].stack = info.stack
gunslinger.__interval[name] = 0
else
-- If LMB not pressed, remove player from list
gunslinger.__automatic[name] = nil
end
end
end
end
Expand Down

0 comments on commit 61e18a5

Please sign in to comment.