mirror of
https://github.com/pandorabox-io/spacecannon.git
synced 2025-01-03 19:37:34 +01:00
add "playername" parameter to spacecannon.can_shoot so it can be overridden elsewhere
fixes #10
This commit is contained in:
parent
bfca9a27e7
commit
8450e4ac70
@ -110,7 +110,9 @@ local register_spacecannon = function(def)
|
||||
|
||||
mesecons = {effector = {
|
||||
action_on = function (pos)
|
||||
spacecannon.fire(pos, def.color, def.speed, def.range)
|
||||
local meta = minetest.get_meta(pos)
|
||||
local owner = meta:get_string("owner")
|
||||
spacecannon.fire(pos, owner, def.color, def.speed, def.range)
|
||||
end
|
||||
}},
|
||||
|
||||
@ -175,7 +177,7 @@ local register_spacecannon = function(def)
|
||||
local meta = minetest.get_meta(pos)
|
||||
|
||||
if fields.fire then
|
||||
spacecannon.fire(pos, def.color, def.speed, def.range)
|
||||
spacecannon.fire(pos, playername, def.color, def.speed, def.range)
|
||||
end
|
||||
|
||||
if fields.set_digiline_channel and fields.digiline_channel then
|
||||
|
@ -83,6 +83,15 @@ Example response from a "fire" request:
|
||||
}
|
||||
```
|
||||
|
||||
# Api
|
||||
|
||||
Modify the ability to shoot depending on position or playername:
|
||||
```lua
|
||||
spacecannon.can_shoot = function(pos, playername)
|
||||
return true
|
||||
end
|
||||
```
|
||||
|
||||
# Contributors
|
||||
|
||||
* @BuckarooBanzay
|
||||
|
6
util.lua
6
util.lua
@ -28,7 +28,7 @@ spacecannon.update_formspec = function(meta)
|
||||
end
|
||||
|
||||
spacecannon.can_shoot = function()
|
||||
-- arguments: pos
|
||||
-- arguments: pos, playername
|
||||
return true
|
||||
end
|
||||
|
||||
@ -37,9 +37,9 @@ spacecannon.can_destroy = function()
|
||||
return true
|
||||
end
|
||||
|
||||
spacecannon.fire = function(pos, color, speed, range)
|
||||
spacecannon.fire = function(pos, playername, color, speed, range)
|
||||
|
||||
if not spacecannon.can_shoot(pos) then
|
||||
if not spacecannon.can_shoot(pos, playername) then
|
||||
return
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user