Compare commits

...

5 Commits

Author SHA1 Message Date
Beha 34d8d2dc2f Update readme.md 2016-01-30 23:11:38 -05:00
Beha f6dd3fa04b 2016 2016-01-15 22:21:50 -05:00
Beha bdd8cf5925 Update readme.md 2015-12-29 10:30:31 -05:00
Beha fe226bfac5 Update readme.md 2015-12-29 10:30:16 -05:00
Beha 96722ad4f2 Generic examples, fix #4 2015-12-29 10:26:51 -05:00
2 changed files with 8 additions and 66 deletions

View File

@ -1,4 +1,4 @@
Copyright (c) 2015 Beha
Copyright (c) 2016 Beha
Permission is hereby granted, free of charge, to any person obtaining a copy
@ -19,4 +19,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.

View File

@ -16,77 +16,19 @@ This argument can be safely ignored, so existing mods aren't broken by this.
In a protection mod change the definition of minetest.is_protected and call `protection_lagporter.check(pos, name)` to support the digging option.
A table of players being teleported is available with `protection_lagporter.glitching`, player names will either be `nil` if not teleporting or `true` if they are.
#### TenPlus1's Protection Redo
function minetest.is_protected(pos, digger)
if not protector.can_dig(protector.radius, pos, digger, false, 1) then
if digging then protection_lagporter.check(pos, name) end
local player = minetest.get_player_by_name(digger)
## Protection Mods
In protection mods simply add `digging` to the definition of `minetest.is_protected`:
if protector.hurt > 0
and player then
player:set_hp(player:get_hp() - protector.hurt)
end
`minetest.isprotected(pos, name, digging)`
if protector.drop == true
and player then
-- drop tool/item if protection violated
local tool = player:get_wielded_item()
--local wear = tool:get_wear()
local num = player:get_wield_index()
local player_inv = player:get_inventory()
local inv = player_inv:get_stack("main", num)
local sta = inv:take_item(inv:get_count())
local obj = minetest.add_item(player:getpos(), sta)
And add this line just before before returning `true`:
if obj then
obj:setvelocity({x = 0, y = 5, z = 0})
player:set_wielded_item(nil)
minetest.after(0.2, function()
player_inv:set_stack("main", num, nil)
end)
end
end
return true
end
return protector.old_is_protected(pos, digger)
end
#### ShadowNinja's Areas
function minetest.is_protected(pos, name, digging)
if not areas:canInteract(pos, name) then
if digging then protection_lagporter.check(pos, name) end
return true
end
return old_is_protected(pos, name, digging)
end
`if digging then protection_lagporter.check(pos, name) end`
## Fast Movement Mods
These mods must be changed to detect `protection_lagporter.glitching`
### Sprint
```
sprint.speed = {}
function setSprinting(playerName, sprinting) --Sets the state of a player (0=stopped/moving, 1=sprinting)
local player = minetest.get_player_by_name(playerName)
if players[playerName] then
if protection_lagporter.glitching[playerName] then
sprint.speed[playerName] = 0.1
end
players[playerName]["sprinting"] = sprinting
if sprinting == true then
player:set_physics_override({speed=SPRINT_SPEED * (sprint.speed[playerName] or 1),jump=SPRINT_JUMP})
elseif sprinting == false then
player:set_physics_override({speed=1.0 * (sprint.speed[playerName] or 1), jump=1.0})
end
return true
end
return false
end
```
These mods must be changed to detect `protection_lagporter.glitching` and set the speed to 0.1 if it is `true` for `protection_lagporter.glitching[playerName]`
#### Node Definitions