mirror of
https://github.com/pandorabox-io/spacecannon.git
synced 2025-01-05 20:37:29 +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 = {
|
mesecons = {effector = {
|
||||||
action_on = function (pos)
|
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
|
end
|
||||||
}},
|
}},
|
||||||
|
|
||||||
@ -175,7 +177,7 @@ local register_spacecannon = function(def)
|
|||||||
local meta = minetest.get_meta(pos)
|
local meta = minetest.get_meta(pos)
|
||||||
|
|
||||||
if fields.fire then
|
if fields.fire then
|
||||||
spacecannon.fire(pos, def.color, def.speed, def.range)
|
spacecannon.fire(pos, playername, def.color, def.speed, def.range)
|
||||||
end
|
end
|
||||||
|
|
||||||
if fields.set_digiline_channel and fields.digiline_channel then
|
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
|
# Contributors
|
||||||
|
|
||||||
* @BuckarooBanzay
|
* @BuckarooBanzay
|
||||||
|
6
util.lua
6
util.lua
@ -28,7 +28,7 @@ spacecannon.update_formspec = function(meta)
|
|||||||
end
|
end
|
||||||
|
|
||||||
spacecannon.can_shoot = function()
|
spacecannon.can_shoot = function()
|
||||||
-- arguments: pos
|
-- arguments: pos, playername
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -37,9 +37,9 @@ spacecannon.can_destroy = function()
|
|||||||
return true
|
return true
|
||||||
end
|
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
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user