[Mod] Node ownership [node_ownership]

User avatar
Menche
Member
Posts: 1001
Joined: Sat Jul 02, 2011 00:43
IRC: Menchers
In-game: Menche
Location: An island in a lava lake.

by Menche » Post

Could this be edited and moved to Mod Releases?
An innocent kitten dies every time you top-post.

thomasP.
Member
Posts: 25
Joined: Mon May 14, 2012 21:05

by thomasP. » Post

what you should do is take the //pos1 and //pos2 thing from worldedit instead of doing a 100,100,100 100,100,100 cuz that can be anoying to do. easier if you can just type //pos1 //pos2 and thats that for setting a region
ingame i am noob

Ancien
Member
Posts: 21
Joined: Fri Jul 06, 2012 09:05

by Ancien » Post

thomasP. wrote:what you should do is take the //pos1 and //pos2 thing from worldedit instead of doing a 100,100,100 100,100,100 cuz that can be anoying to do. easier if you can just type //pos1 //pos2 and thats that for setting a region
+1

User avatar
cactuz_pl
Member
Posts: 876
Joined: Tue Jun 05, 2012 16:34
Location: Poland

by cactuz_pl » Post

This mod doesn't protect against spilling lava or water. Is there a way to improve this code and prevent spilling on protected areas?
Nope

SegFaulter

by SegFaulter » Post

For some reason, when I try to remove the owner of an area that I set for that area, nothing happens. I accidentally set the owner of a house in ecube's server, but I meant to set myself as the owner of the city and add owners for each lot.
The lot is in the owner's list as area #3.
Can someone help me get this to work right?

wieszak
Member
Posts: 40
Joined: Mon Feb 20, 2012 17:00

by wieszak » Post

Ok, i have two strong suggesttion:
First: optimization:

Code: Select all

function minetest.item_place(itemstack, placer, pointed_thing)
        if itemstack:get_definition().type == "node" then
                local pos = pointed_thing.above

                if HasOwner(pos) then  
-- this is pointless as next function check the exactly same thing: return true when player is owner of area OR there is no owner, so this check here only adds cost.


                        if not IsPlayerNodeOwner(pos, placer:get_player_name()) then
                                minetest.chat_send_player(placer:get_player_name(), "You can not place nodes here.")
                                return itemstack
                        end
                end
                return old_node_place(itemstack, placer, pointed_thing)
        end
        
        return old_node_place(itemstack, placer, pointed_thing)
end

second thing: on redcrab server there was crashes when removing some area, debug tells that is stack overflow related. Therefore i suggest double check in the only recursive function:

Code: Select all

function RemoveTableEntryRe(r_id)
        --Find child entries and remove them
        for n,def in pairs(owner_defs) do
 -- if delete flag is set, so this branch was already visited - you can even issue a error message here - it should not happen
              if def.parent == r_id and not def.delete then 
                        def.delete = true
                        RemoveTableEntryRe(def.id)
                end
        end
        -- now remove main entry
        for n,def in pairs(owner_defs) do
                if def.id == r_id then
                        table.remove(owner_defs, n)
                        break
                end
        end
end

function RemoveTableEntry(r_id)
        -- initialize 'guardians'
         for n,def in pairs(owner_defs) do
                def.delete = false
          end

        RemoveTableEntryRe(r_id)
        
        --Re-number ids to match place in table
        for n,ndef in pairs(owner_defs) do
                if ndef.id ~= n then
                        for p,pdef in pairs(owner_defs) do
                                if pdef.parent == ndef.id then
                                        pdef.parent = n
                                end
                        end
                        ndef.id = n
                end
        end
        
        table_save( owner_defs, owners_db_filename )
end

Last edited by wieszak on Tue Sep 11, 2012 20:08, edited 1 time in total.

joker333
Member
Posts: 13
Joined: Sat Sep 15, 2012 22:10

by joker333 » Post

im canfused as to how to set an area like how can u make it where it sests it to a sertent depth an hight in the sky plus the with in every direction???
if that makes any seens

User avatar
redcrab
Member
Posts: 833
Joined: Tue Dec 13, 2011 13:45
Location: France
Contact:

by redcrab » Post

After big issues with this mod when you try to "/remove_areas" but with a too large protected area list (lua stackoverflow error, with server crash and often sqlite map corrupted afterward)...

I 've updated the lua code to place a fix ... it works so far ...

original code

Code: Select all

function RemoveTableEntryRe(r_id)
    --Find child entries and remove them
    for n,def in pairs(owner_defs) do
        if def.parent == r_id then
            RemoveTableEntryRe(def.id)
        end
    end
    -- now remove main entry
    for n,def in pairs(owner_defs) do
        if def.id == r_id then
            table.remove(owner_defs, n)
            break
        end
    end
end

function RemoveTableEntry(r_id)
    RemoveTableEntryRe(r_id)
    --Re-number ids to match place in table
    for n,ndef in pairs(owner_defs) do
        if ndef.id ~= n then
            for p,pdef in pairs(owner_defs) do
                if pdef.parent == ndef.id then
                    pdef.parent = n
                end
            end
            ndef.id = n
        end
    end
    table_save( owner_defs, owners_db_filename )
end
replaced by

Code: Select all

function RemoveTableEntry(r_id)
    --Find child entries and remove them
    local nomorechild = true
    repeat
        nomorechild = true
        for n,def in pairs(owner_defs) do
            if def.parent == r_id then
                table.remove(owner_defs, n) --RemoveTableEntryRe(def.id)
                nomorechild = false
                break
            end
        end
    until nomorechild
    -- now remove main entry
    for n,def in pairs(owner_defs) do
        if def.id == r_id then
            table.remove(owner_defs, n)
            break
        end
    end
    --Re-number ids to match place in table
    for n,ndef in pairs(owner_defs) do
        if ndef.id ~= n then
            for p,pdef in pairs(owner_defs) do
                if pdef.parent == ndef.id then
                    pdef.parent = n
                end
            end
            ndef.id = n
        end
    end
     table_save( owner_defs, owners_db_filename )
end

Last edited by redcrab on Thu Sep 20, 2012 13:18, edited 1 time in total.
0.4 for serious builder click here
Dedicated Minetest redcrab server forum at http://minetestbb.suret.net

It's nice to be important but it is more important to be nice.

wieszak
Member
Posts: 40
Joined: Mon Feb 20, 2012 17:00

by wieszak » Post

This is wrong - it will not delete area which has area which has area. If you want make it by iterations not recursive, you should not delete entries, but mark them to be deleted, then for all marked entries check again if they have childs and mark them if find, and repeat it until no more childs found, then delete all marked entries.

mike
Member
Posts: 46
Joined: Wed Sep 26, 2012 01:15

by mike » Post

I did some change to the code:

1. added redcrabs fix
2. figured out, that the changes of the core minetest application are already built into. so diff files can be dropped.
3. locked the whole world, so noone can dig/place everywhere without concession
4. added a sandbox user. if you grant the sandbox user an area, everyone with interact can edit this.
you can also give subconcessions to the sandbox user if you are a concessionaire of an area.
for example you want to have a trading/play place in your home.
5. added a griefing priv, so players with "griefing" priv set can dig/place everywhere on the map
6. added coords and grantor/concessionaire output on blocked action.

planned:
- fix redcrabs recursion problem (if it exists) or add an depth lock for childs to just one level of childs.
- cleanup code and put hardcoded stuff into statics at top of the file

maybe:
- add a gui

offtopic: added a priv "creative" to the creative inventory, so only these players get the creative inventory.

i will release the code here soon.
if someone wants to work on this mod it would be nice to cooperate.
Last edited by mike on Wed Sep 26, 2012 01:33, edited 1 time in total.

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

by cornernote » Post

hi Mike, put it on github so others can fork and then push changes back

mike
Member
Posts: 46
Joined: Wed Sep 26, 2012 01:15

by mike » Post

https://github.com/codeandfix/node_ownership

this is not the announced release.. just an alpha of the current state!
but it works mostly..

mike
Member
Posts: 46
Joined: Wed Sep 26, 2012 01:15

by mike » Post

for ongoing changes see commit logs.

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

by cornernote » Post

it seems randomproof has not been on the forums for a few months. i think if you are actively developing this mod then your repo should be considered the most up-to-date (i had to stop myself using the word "master").

i recommend creating a new thread so that you can manage the first post.

once done, ask the forum mods to mark this one as old

remember to give credit back to this mod in your thread/readme/etc taking into account the current license. With GPL I think you can just add yourself to the list of copyright people, and then re-release it under GPL.

mike
Member
Posts: 46
Joined: Wed Sep 26, 2012 01:15

by mike » Post

- subconcessions from childs to childs are forbidden now, to circumvent problems with recursive deletion.
- code cleaned up a bit

get latest version here
https://github.com/codeandfix/node_ownership/
Last edited by mike on Fri Sep 28, 2012 17:06, edited 1 time in total.

User avatar
RAPHAEL
Member
Posts: 627
Joined: Tue Nov 01, 2011 09:09
Location: Earth

by RAPHAEL » Post

"Fixed" node_ownership..

Whole world diggable by default. Only owned land cannot be dug by anyone except owner.

http://ompldr.org/vZ25wMw
"Before you speak, ask yourself: Is it kind, is it true, is it necessary, does it improve upon the silence?"
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)

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

by VanessaE » Post

Can someone tell me just how to let this mod know that I am the admin of my own server (so I can do routine maintenance)? :-)
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

User avatar
RAPHAEL
Member
Posts: 627
Joined: Tue Nov 01, 2011 09:09
Location: Earth

by RAPHAEL » Post

VanessaE wrote:Can someone tell me just how to let this mod know that I am the admin of my own server (so I can do routine maintenance)? :-)
I think you edit the settings file and change ServerAdmin to your player name.
"Before you speak, ask yourself: Is it kind, is it true, is it necessary, does it improve upon the silence?"
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)

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

by VanessaE » Post

That only affects some chat/print output.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

User avatar
RAPHAEL
Member
Posts: 627
Joined: Tue Nov 01, 2011 09:09
Location: Earth

by RAPHAEL » Post

VanessaE wrote:That only affects some chat/print output.
You sure? If that's not the case then I presume you need some form of server privs (unsure which). On DTAmedia server I have two people as able to use node_ownership and only thing that was done is editing that settings file. Of course both also have all the server privs.
"Before you speak, ask yourself: Is it kind, is it true, is it necessary, does it improve upon the silence?"
My mods: http://goo.gl/n4kpn
(Currently Various, Industrial, Fakeblocks, Jail, MoarCraft, Christmas, Replicator, minetest dev installer for linux, bash mod installer, windows mod installer)

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

by VanessaE » Post

Yep, I looked at the code and didn't see any use of that variable that was part of an actual piece of code.
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

User avatar
Menche
Member
Posts: 1001
Joined: Sat Jul 02, 2011 00:43
IRC: Menchers
In-game: Menche
Location: An island in a lava lake.

by Menche » Post

Use "name = [your name]" to set the admin. You then have all privs automatically and they can't be revoked.
Last edited by Menche on Sat Dec 15, 2012 16:22, edited 1 time in total.
An innocent kitten dies every time you top-post.

mike
Member
Posts: 46
Joined: Wed Sep 26, 2012 01:15

by mike » Post

I suggest to visit https://github.com/codeandfix/node_ownership/ and read the huge manual!

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

by VanessaE » Post

Menche: Actually node_ownership ignores/overrides that.

No matter, here's my variation of this mod. All this does is allow the user to tell the mod who the server admin is by uncommenting and changing the SERVER_ADMIN variable in settings.lua. The actual tweak to make it work was done inside the HasOwner() function. If a player with that name attempts to dig/place, the mod bypasses its usual protection code and just lets the action happen.

http://digitalaudioconcepts.com/vanessa ... 130123.zip
You might like some of my stuff: Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (64-512px)

ssieb
Member
Posts: 14
Joined: Mon Apr 08, 2013 19:51
GitHub: ssieb
IRC: ssieb

by ssieb » Post

It would be nice if the client had some concept of the permissions. As it is (especially if the server is lagging), it's possible to dig through a wall to get inside a protected area. Sure, the server makes the blocks go back, but the player is already inside.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests