Page 1 of 1

[antigrief][code] Universal Node-Ownership, Water/Lava Safeties

PostPosted: Wed Jun 27, 2012 14:20
by mauvebic
Universal node ownership

each node placed records its owner. Blocks placed by the servers' mapgen, or mods, are diggable. Nodes w/ owners can be removed using worldedit or multinode, or whatever tool mod that removes nodes instead of digging them.
Theres nothing to download, since your placing and replacing snippets of code in builtin/misc_register.lua and default/init.lua

PostPosted: Wed Jun 27, 2012 17:59
by neo
Interesting. What are you playing with ?

PostPosted: Wed Jun 27, 2012 18:14
by neo
the code ! the code !

PostPosted: Sun Jul 29, 2012 15:03
by mauvebic
update

PostPosted: Mon Jul 30, 2012 06:36
by cornernote
add this in builtin.lua, add this line (just under misc_register):
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
dofile(minetest.get_modpath("__builtin").."/my_file.lua")


Then you can add the rest into a file of its own:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
local function is_node_owner(meta, player)
    if meta:get_string("owner") ~= player:get_player_name() and meta:get_string("owner") ~= '' then
        return false
    end
    return true
end
local can_dig = function(pos,player)
    meta = minetest.env:get_meta(pos)
    return is_node_owner(meta, player)
end

-- copy minetest.register_node to another function so we can still call it
minetest_register_node = minetest.register_node;

-- overwrite minetest.register_node
function minetest.register_node(name, nodedef)
    if not nodedef.can_dig then nodedef.can_dig = can_dig end
    minetest_register_node(name, nodedef) -- call the real minetest.register_node
end

minetest.register_on_placenode(function(p, node, placer)
    local meta = minetest.env:get_meta(p)
    local player = placer:get_player_name()
    meta:set_string("owner",player)
end)



p.s. awesome mod! very small but very useful

PostPosted: Mon Jul 30, 2012 10:45
by mauvebic
Well its not perfect (no antigriefing solution is 100%) - this one doesn't use zones so there's no hassle in setting them up, but if someone decides to strategically place nodes to block pathways and such, then it could be hassle having to remove them with wolrdedit or multinode (but by then youll probably ban the person for doing such, so at least they were never able to destroy any buildings)

I dont know how pertinent this mod is going to be once c55 is done implementing rollback. (saw a few references to it in the code). Im already not crazy about rollback, yesterday id find myself placing 20-30 nodes, then they'd all disappear, and come back again (wtf? lol)

PostPosted: Wed Aug 01, 2012 01:39
by mauvebic
update posted :-)

PostPosted: Tue Aug 07, 2012 23:41
by SegFault22
yesterday id find myself placing 20-30 nodes, then they'd all disappear, and come back again

That is called ''node prediction'' or something, when you place a node, Minetest predicts the node's position/collision box. Sometimes the server sends back the data for that area, before it gets the data that you changed the area, and the nodes will ''disappear'', until the server processes the data and sends the packet(s) with the data of the area back to the client. It has nothing to do with rollback.