unbreakable blocks & set_player_privs won't?

User avatar
AiTechEye
Member
 
Posts: 409
Joined: Fri May 29, 2015 21:14

unbreakable blocks & set_player_privs won't?

by AiTechEye » Thu Jun 11, 2015 08:02

1: How can i see if a node is unbreakable or have no drops?
node= minetest.get_node(pos)
node.?

cant find anything about it


2: It can set player privs without any problems, but to remove / revoke it, i have to restart the server before it disappear?
Tested in 0.4.12 / dev

local privs=minetest.get_player_privs(name)
if priv=="fly" then
privs.fly = true
privs.fantasticdrinks_fly = true
end

if priv=="fast" then
privs.fast = true
privs.fantasticdrinks_fast = true
end
minetest.set_player_privs(name, privs)

...
local privs=minetest.get_player_privs(name)

if priv=="fly" then
privs.fly = false
privs.fantasticdrinks_fly = false
end
if priv=="fast" then
privs.fast = false
privs.fantasticdrinks_fast = false
end

minetest.set_player_privs(name, privs)
Alive AI Mine/Build AI NPC
Gravitygun HL2
Portalgun Portal
Marssurvive Survive on mars
Bows bows + arrows
SoundCloud (Music)
SoundCloud (Classic)
YouTube
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: unbreakable blocks & set_player_privs won't?

by rubenwardy » Thu Jun 11, 2015 10:06

The immortal group is probably what you're looking for, although some mods such as tnt don't respect it.

Be warned with privs that they don't work on single player or if you're an admin (you automatically get all privs)
 

User avatar
AiTechEye
Member
 
Posts: 409
Joined: Fri May 29, 2015 21:14

Re: unbreakable blocks & set_player_privs won't?

by AiTechEye » Thu Jun 11, 2015 13:10

1: I already know this, the problem is:
can i see if the node is immortal or not have drops ?
2:
minetest.set_player_privs wont revoke/remove any privs?
Alive AI Mine/Build AI NPC
Gravitygun HL2
Portalgun Portal
Marssurvive Survive on mars
Bows bows + arrows
SoundCloud (Music)
SoundCloud (Classic)
YouTube
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: unbreakable blocks & set_player_privs won't?

by rubenwardy » Thu Jun 11, 2015 13:22

I really don't understand your 1. Is this what you meant:

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 node = minetest.get_node(pos)
if node and node.name and node.name ~= "" then
    local nodedef = minetest.registered_nodes[node.name]
    if nodedef.groups and nodedef.groups['immortal'] > 0 then
        -- is immortal
    end

    if nodedef.drop and nodedef.drop.max_items == 0 then
        -- drops nothing. Note, will also drop nothing if immortal, because won't dig, so you may want to check for that
    end
end
 

User avatar
AiTechEye
Member
 
Posts: 409
Joined: Fri May 29, 2015 21:14

Re: unbreakable blocks & set_player_privs won't?

by AiTechEye » Thu Jun 11, 2015 15:48

Yeah it's exactly, thanks :D

Because I using much minetest.node dig, then i have to make people can't use craftable tools to break into everywhere.
Alive AI Mine/Build AI NPC
Gravitygun HL2
Portalgun Portal
Marssurvive Survive on mars
Bows bows + arrows
SoundCloud (Music)
SoundCloud (Classic)
YouTube
 

User avatar
Wuzzy
Member
 
Posts: 2161
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy

Re: unbreakable blocks & set_player_privs won't?

by Wuzzy » Sun Jun 21, 2015 11:49

UjEdwin wrote:1: How can i see if a node is unbreakable or have no drops?
node= minetest.get_node(pos)
node.?


The first part is a bit tricky, because you have to set a couple of variables in the node definition to make a block truly unbreakable.

Checking against the group “immortal” might suffice in most of the cases, but be aware that this only means the block cannot be broken by digging. It could still be possible that the block can be destroyed by other circumstances, for example, explosions.
If you just want to check whether the block cannot be dug, you are probably already done by checking against “immortal”. But to be sure, you also might to check against “diggable” (should be false).

I have written about unbreakable (at least in normal gameplay) blocks here:
viewtopic.php?f=3&t=11401&hilit=unbreakable#p172046

If you want to check whether the block in question is “unbreakable” in some other aspect, just ask.


Because I using much minetest.node dig, then i have to make people can't use craftable tools to break into everywhere.

The normal way to remove a single block reliably is by using minetest.remove_node. However, I do not recommend using this function for uses other than just testing and debugging. I recommend against using it for normal gameplay. You must ask yourself the question: Do you really want a craftable tool which breaks every block, including those which may come from mods, including blocks which are normally not supposed to be broken at all, i.e. bedrock?

Just tell us what you actually want to achieve, then I may try to help.
 


Return to Modding Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron