Generic examples, fix #4
parent
a1bd1f6298
commit
96722ad4f2
70
readme.md
70
readme.md
|
@ -16,77 +16,13 @@ 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)
|
||||
|
||||
if protector.hurt > 0
|
||||
and player then
|
||||
player:set_hp(player:get_hp() - protector.hurt)
|
||||
end
|
||||
|
||||
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)
|
||||
|
||||
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
|
||||
## Protection Mods
|
||||
In protection mods simply add `diggging` to the definition of `minetest.is_protected`: `minetest.isprotected(..., digging)` and add this line just before before returning `true`: `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
|
||||
|
|
Loading…
Reference in New Issue