[Mod] Protector [0.1] [protector]

glomie
Member
 
Posts: 141
Joined: Sun Aug 07, 2011 19:41

[Mod] Protector [0.1] [protector]

by glomie » Wed Aug 15, 2012 17:39

Adds a block for area protecting.

Area is protected for five block in each of six direction

Screenshot : Image
Mod dependencies: default, moreores
Download: --dead link deleted--
Last edited by glomie on Sun Aug 19, 2012 11:25, edited 1 time in total.
Sorry for my bad english...
 

tinoesroho
Member
 
Posts: 570
Joined: Fri Feb 17, 2012 21:55
Location: Canada

by tinoesroho » Wed Aug 15, 2012 20:19

Screenshot or it didn't happen.
We are what we create.

I tinker and occasionally make (lousy) mods. Currently building an MMO subgame and updating mods. Pirate Party of Canada member. Sporadic author. 21 years old.

My github:
https://github.com/tinoesroho/
 

glomie
Member
 
Posts: 141
Joined: Sun Aug 07, 2011 19:41

by glomie » Sat Aug 18, 2012 20:59

tinoesroho wrote:Screenshot or it didn't happen.

didn't happen what ?
Sorry for my bad english...
 

User avatar
madchicken13
Member
 
Posts: 741
Joined: Mon Jun 11, 2012 00:41
Location: Shelton, WA
 

Temperest
Member
 
Posts: 651
Joined: Tue Nov 15, 2011 23:13
GitHub: Uberi

by Temperest » Sat Aug 18, 2012 22:55

glomie wrote:
tinoesroho wrote:Screenshot or it didn't happen.

didn't happen what ?


I believe that means that tinoesroho is requesting that you add screenshots of the mod in action.
WorldEdit 1.0 released

The Mesecons Laboratory - the art of Mesecons circuitry
Latest article: Mesecons Basics.
 

User avatar
NakedFury
Member
 
Posts: 151
Joined: Thu Dec 08, 2011 03:55

by NakedFury » Sun Aug 19, 2012 02:37

It is sort of required for a mod creator to ALWAYS include screenshots or videos of the mod in action.

In your case a video would be more appropriate.
 

cornernote
Member
 
Posts: 844
Joined: Wed Jul 11, 2012 15:02

by cornernote » Sun Aug 19, 2012 03:16

A screenshot of someone not able to place a block?

I don't see how a screenshot would help this mod. Screenshots are used to show what a mod looks like. This mod doesn't look like anything, it has functionality.

Videos take a bit of effort. I dont think this mod needs the author to create one. People should be able to understand what it does based on the description.
 

User avatar
mrtux
Member
 
Posts: 141
Joined: Mon Jun 25, 2012 02:41

by mrtux » Sun Aug 19, 2012 06:35

I like this mod! Sadly griefers can make a building their own so that may cause problems.
+100
thanks doge
 

glomie
Member
 
Posts: 141
Joined: Sun Aug 07, 2011 19:41

by glomie » Sun Aug 19, 2012 11:28

(firts post updated)

vortexlabs wrote:I like this mod! Sadly griefers can make a building their own so that may cause problems.
+100

For now grieffer don't build anything
Sorry for my bad english...
 

Tulio
New member
 
Posts: 3
Joined: Fri Oct 12, 2012 20:27
Location: Ipatinga,Minas Gerais,Brasil

by Tulio » Sun Oct 14, 2012 23:47

How does the protection which blocks him and crafting ?
 

Dragonop
Member
 
Posts: 1178
Joined: Tue Oct 23, 2012 12:59
Location: Argentina
GitHub: Dragonop
IRC: Dragonop
In-game: Dragonop

by Dragonop » Wed Oct 24, 2012 18:38

I don't understand
If you have any pending matters with me, I encourage you to contact me via e-mail or PM. I still lurk from the shadows and very much care about the Minetest project. Sadly I have not been involved for the past years but I still look back fondly on the time I spent in your company.
If you are checking my profile, it's probably because of something.

It's "Drag" for the friends.

https://forum.minetest.net/download/file.php?id=4472
 

redblades
New member
 
Posts: 7
Joined: Fri Oct 19, 2012 19:23

by redblades » Wed Oct 24, 2012 21:47

basically from my understanding, the protector is in the middle of a 13x13x13 cube of protected area. it works great, nobody but you can build or destroy anything in the cube area.
I like pie
 

User avatar
0gb.us
Member
 
Posts: 841
Joined: Sun Sep 16, 2012 01:55
Location: 0gb.us:30000

by 0gb.us » Thu Oct 25, 2012 00:25

redblades wrote:basically from my understanding, the protector is in the middle of a 13x13x13 cube of protected area. it works great, nobody but you can build or destroy anything in the cube area.


It's 11^3, but yeah, that's how it works.
 

User avatar
Zeg9
Member
 
Posts: 608
Joined: Fri Sep 21, 2012 11:02
Location: France

by Zeg9 » Mon Nov 05, 2012 15:41

Here is a version which allows multiple members (that can build/dig within the area):

Code: Select all
minetest.register_craft({
    output = 'protector:protect 16',
    recipe = {
        {'moreores:silver_ingot', 'moreores:silver_ingot'},
        {'moreores:silver_ingot', 'moreores:silver_ingot'},
    }
})


function isprotect(r,pos,digger,onlyowner)
    if pos.y < -999 then
        return false
    end
    local ok=true
    for ix = pos.x-r,pos.x+r do
        for iy = pos.y-r,pos.y+r do
            for iz = pos.z-r,pos.z+r do
                local node_name = minetest.env:get_node({x=ix,y=iy,z=iz})
                if node_name.name == "protector:protect" then
                    local meta = minetest.env:get_meta({x=ix,y=iy,z=iz})
                    if digger ~= nil then
                        local owner = (meta:get_string("owner"))                   
                            if owner ~= digger:get_player_name() then
                                ok=false
                                if not onlyowner and string.find(' '..meta:get_string("members")..' ', ' '..digger:get_player_name()..' ')
                                then ok=true end
                                if not ok then return false end
                            end
                        end           
                end
            end
        end
    end
    return true
end

local old_node_dig = minetest.node_dig
function minetest.node_dig(pos, node, digger)
    local ok=true
    if node.name ~= "protector:protect" then
    ok = isprotect(5,pos,digger)
    else ok = isprotect(5,pos,digger,true)
    end
    if ok == true then
        old_node_dig(pos, node, digger)
    else
        minetest.chat_send_player(digger:get_player_name(), "area protected")
        return
    end
end

local old_node_place = minetest.item_place
function minetest.item_place(itemstack, placer, pointed_thing)
    if itemstack:get_definition().type == "node" then
        local ok=true
        if itemstack:get_name() ~= "protector:protect" then
            local pos = pointed_thing.above
            ok = isprotect(5,pos,placer)
        else
            local pos = pointed_thing.above
            ok = isprotect(10,pos,placer,true)
        end
        if ok == true then
            if itemstack:get_name() == "protector:protect" then
                local pos = pointed_thing.above
                --minetest.chat_send_player(placer:get_player_name(), "this block protect ( "..
                --tostring(pos.x-3) .. " to " .. tostring(pos.x+3).." , "..
                --tostring(pos.y-3) .. " to " .. tostring(pos.y+3).." , "..
                --tostring(pos.z-3) .. " to " .. tostring(pos.z+3).." )"
                --)
            end
            return old_node_place(itemstack, placer, pointed_thing)
        else
            minetest.chat_send_player(placer:get_player_name(), "area protected")
            return
        end   
    end   
    return old_node_place(itemstack, placer, pointed_thing)
end
protect = {}
minetest.register_node("protector:protect", {
    description = "protect",
    tile_images = {"glo2.png"},
    groups = {cracky=3},
    after_place_node = function(pos, placer)
        local meta = minetest.env:get_meta(pos)
        meta:set_string("owner", placer:get_player_name() or "")
        meta:set_string("infotext", "protect (owned by "..
                meta:get_string("owner")..")")
        meta:set_string("members", "")
        meta:set_string("formspec",
            "size[6,4]"..
            "label[0,0;Protect owned by "..meta:get_string("owner").."]"..
            "field[.25,1.25;6,1;members;Members (put spaces between each name):;"..meta:get_string("members").."]"..
            "button_exit[0,2;2,1;ok;Save]")
    end,
    on_receive_fields = function(pos,formname,fields,sender)
        local meta = minetest.env:get_meta(pos)
        if sender:get_player_name() == meta:get_string("owner") then
            if fields.members then
                meta:set_string("members",fields.members)
                meta:set_string("formspec",
                    "size[6,4]"..
                    "label[0,0;Protect owned by "..meta:get_string("owner").."]"..
                    "field[.25,1.25;6,1;members;Members (put spaces between each name):;"..meta:get_string("members").."]"..
                    "button_exit[0,2;2,1;ok;Save]")
       
            end
        end
    end,
})


Right click a protect block to edit the members list (names are separated with spaces).
Members can't remove the protect block, only owner can.
I made a few (a lot of?) mods for minetest: here is a list.
See also the MT-Faithful texture pack (work in progress).
 

User avatar
VanessaE
Moderator
 
Posts: 4463
Joined: Sun Apr 01, 2012 12:38
Location: Waynesville, NC
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaE

by VanessaE » Fri Nov 09, 2012 17:24

Zeg9, could you and glomie turn your fork into a downloadable mod and replace the dead link in the first post? Thanks.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)
 

User avatar
Zeg9
Member
 
Posts: 608
Joined: Fri Sep 21, 2012 11:02
Location: France

by Zeg9 » Fri Nov 09, 2012 19:48

Here is a .zip of mine:
http://ompldr.org/vZzdseQ
I made a few (a lot of?) mods for minetest: here is a list.
See also the MT-Faithful texture pack (work in progress).
 

glomie
Member
 
Posts: 141
Joined: Sun Aug 07, 2011 19:41

by glomie » Wed Jun 12, 2013 20:10

Not the original, but this one have south privs, remove protect from banned player, and add bedrock at -1000:
Code: Select all
minetest.register_privilege('south', 'south build')


minetest.register_craft({
    output = 'protector:protect 16',
    recipe = {
        {'gloopores:kalite_ingot', 'gloopores:kalite_ingot'},
        {'gloopores:kalite_ingot', 'gloopores:kalite_ingot'},
    }
})
minetest.register_craft({
    output = 'protector:protect_glass',
    recipe = {
        {'default:glass'},
        {'protector:protect'},
    }
})
function inlist(list,truc)
        for i,ilist in ipairs(list) do
                if truc == ilist then
                        return true
                end
        end
        return false
end





function split(s,re) --http://snippets.luacode.org/?p=snippets/Split_a_string_into_a_list_5
        local i1 = 1
        local ls = {}
        local append = table.insert
        if not re then
                re = '%s+'
        end
        if re == '' then
                return {s}
        end

       while true do
                local i2,i3 = s:find(re,i1)
                if not i2 then
                        local last = s:sub(i1)
                        if last ~= '' then
                                append(ls,last)
                        end
                        if #ls == 1 and ls[1] == '' then
                                return {}
                        else   
                                return ls
                        end
                end
                append(ls,s:sub(i1,i2-1))
                i1 = i3+1
        end
end

if 1==1 then
minetest.register_abm(
                {nodenames = {"protector:protect"},
                interval = 5,
                chance = 1,
                action = function(pos)
                                        meta = minetest.env:get_meta(pos)
                                        owner = (meta:get_string("owner"))
                                        lb=split(minetest.get_ban_list(),',')
                                        listban={'Test_ban'}
                                        for i,j in ipairs(lb) do
                                                table.insert(listban,split(j,'|')[2])
                                        end
                                        if inlist(listban,owner) == true then
                                                minetest.env:add_node(pos, {name="default:stone"})
                                        end
                end,
})
end


function isprotect(r,pos,digger,onlyowner)
        if pos.y < -999 then
        for ix = pos.x-50,pos.x+50 do
            for iz = pos.z-50,pos.z+50 do
                minetest.env:add_node({x=ix,y=pos.y,z=iz}, {name="bedrock:bedrock"})
            end
        end
            return false
        end
    if pos.z < 1 then
        if minetest.check_player_privs(digger:get_player_name(), {south=true})~=true then
            return false
        end
    end
   
    local ok=true
    for ix = pos.x-r,pos.x+r do
        for iy = pos.y-r,pos.y+r do
            for iz = pos.z-r,pos.z+r do
                local node_name = minetest.env:get_node({x=ix,y=iy,z=iz})
                if node_name.name == "protector:protect" then
                    local meta = minetest.env:get_meta({x=ix,y=iy,z=iz})
                    if digger ~= nil then
                        local owner = (meta:get_string("owner"))                   
                            if owner ~= digger:get_player_name() then
                                ok=false
                                if not onlyowner and string.find(' '..meta:get_string("members")..' ', ' '..digger:get_player_name()..' ')
                                then ok=true end
                                if not ok then return false end
                            end
                        end           
                end
            end
        end
    end
    return true
end

local old_node_dig = minetest.node_dig
function minetest.node_dig(pos, node, digger)
    local ok=true
    if node.name ~= "protector:protect" then
    ok = isprotect(5,pos,digger)
    else ok = isprotect(5,pos,digger,true)
    end
    if ok == true then
        old_node_dig(pos, node, digger)
    else
        minetest.chat_send_player(digger:get_player_name(), "area protected")
        return
    end
end

local old_node_place = minetest.item_place
function minetest.item_place(itemstack, placer, pointed_thing)
    if itemstack:get_definition().type == "node" then
        local ok=true
        if itemstack:get_name() ~= "protector:protect" then
            local pos = pointed_thing.above
            ok = isprotect(5,pos,placer)
        else
            local pos = pointed_thing.above
            ok = isprotect(10,pos,placer,true)
        end
        if ok == true then
            if itemstack:get_name() == "protector:protect" then
                local pos = pointed_thing.above
                --minetest.chat_send_player(placer:get_player_name(), "this block protect ( "..
                --tostring(pos.x-3) .. " to " .. tostring(pos.x+3).." , "..
                --tostring(pos.y-3) .. " to " .. tostring(pos.y+3).." , "..
                --tostring(pos.z-3) .. " to " .. tostring(pos.z+3).." )"
                --)
            end
            return old_node_place(itemstack, placer, pointed_thing)
        else
            minetest.chat_send_player(placer:get_player_name(), "area protected")
            return
        end   
    end   
    return old_node_place(itemstack, placer, pointed_thing)
end
protect = {}
minetest.register_node("protector:protect", {
    description = "protect",
    tile_images = {"glo2.png"},
    groups = {cracky=3},
    after_place_node = function(pos, placer)
        local meta = minetest.env:get_meta(pos)
        meta:set_string("owner", placer:get_player_name() or "")
        meta:set_string("infotext", "protect (owned by "..
                meta:get_string("owner")..")")
        meta:set_string("members", "")
        meta:set_string("formspec",
            "size[6,4]"..
            "label[0,0;Protect owned by "..meta:get_string("owner").."]"..
            "field[.25,1.25;6,1;members;Members (put spaces between each name):;"..meta:get_string("members").."]"..
            "button_exit[0,2;2,1;ok;Save]")
    end,
    on_receive_fields = function(pos,formname,fields,sender)
        local meta = minetest.env:get_meta(pos)
        if sender:get_player_name() == meta:get_string("owner") then
            if fields.members then
                meta:set_string("members",fields.members)
                meta:set_string("formspec",
                    "size[6,4]"..
                    "label[0,0;Protect owned by "..meta:get_string("owner").."]"..
                    "field[.25,1.25;6,1;members;Members (put spaces between each name):;"..meta:get_string("members").."]"..
                    "button_exit[0,2;2,1;ok;Save]")
       
            end
        end
    end,
})
minetest.register_node("protector:protect_glass", {
    description = "transparent protect",
    tile_images = {"protect_glass.png"},
    drawtype = "glasslike",
    groups = {cracky=3},
    paramtype = "light",
    sunlight_propagates = true,
    after_place_node = function(pos, placer)
        local meta = minetest.env:get_meta(pos)
        meta:set_string("owner", placer:get_player_name() or "")
        meta:set_string("infotext", "protect (owned by "..
                meta:get_string("owner")..")")
        meta:set_string("members", "")
        meta:set_string("formspec",
            "size[6,4]"..
            "label[0,0;Protect owned by "..meta:get_string("owner").."]"..
            "field[.25,1.25;6,1;members;Members (put spaces between each name):;"..meta:get_string("members").."]"..
            "button_exit[0,2;2,1;ok;Save]")
    end,
    on_receive_fields = function(pos,formname,fields,sender)
        local meta = minetest.env:get_meta(pos)
        if sender:get_player_name() == meta:get_string("owner") then
            if fields.members then
                meta:set_string("members",fields.members)
                meta:set_string("formspec",
                    "size[6,4]"..
                    "label[0,0;Protect owned by "..meta:get_string("owner").."]"..
                    "field[.25,1.25;6,1;members;Members (put spaces between each name):;"..meta:get_string("members").."]"..
                    "button_exit[0,2;2,1;ok;Save]")
       
            end
        end
    end,
})
Sorry for my bad english...
 


Return to WIP Mods



Who is online

Users browsing this forum: No registered users and 10 guests