New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add 'creative' privilege for survival servers #1543
Conversation
Very useful for admins/moderators to work on ingame infrastructure without using cumbersome /giveme whatever... |
mods/creative/init.lua
Outdated
@@ -54,7 +57,7 @@ function minetest.handle_node_drops(pos, drops, digger) | |||
end | |||
local inv = digger:get_inventory() | |||
if inv then | |||
for _, item in ipairs(drops) do | |||
for _, item in pairs(drops) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pairs is slightly faster than ipairs when dealing with tables not containing numbers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not exactly performance-critical code...
Whether pairs
or ipairs
is faster also depends on implementation:
local t = {1,1,2,3,5,8,13,21,34,55}
local function timeit(f)
local n = 0
local start = os.clock()
for i = 1, 1000 do
for _, x in f(t) do
n = n + x
end
end
return os.clock()-start
end
print("ipairs:", timeit(ipairs))
print("pairs:", timeit(pairs))
# luajit pairs.lua
ipairs: 0.000156
pairs: 0.000598
# lua5.1 pairs.lua
ipairs: 0.001272
pairs: 0.001225
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that ipairs and luajit work well together :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can change behaviour of the code; it is also not performance-critical.
👍 |
mods/creative/init.lua
Outdated
@@ -1,14 +1,17 @@ | |||
creative = {} | |||
|
|||
minetest.register_privilege("creative", {"Allow player to use creative inventory", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description =
?
Does this even work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's running on Xanadu for now where admin have 'creative' privelages and access to the creative inventory/placement features.
This doesn't look so bad. But the new priv should be added to |
Once the callbacks have been added for giving/revoking privs then we can tinker with the creative inventory side of things, but until then it'll set inventory on join. |
mods/creative/init.lua
Outdated
@@ -1,14 +1,18 @@ | |||
creative = {} | |||
|
|||
minetest.register_privilege("creative", { | |||
description = "Allow player to use creative inventory", | |||
give_to_singleplayer = false}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use tabs here, as above in description
.
Weird, says branch has conflicts even when it hasn't... what's up with travis ?!?! |
This adds a 'creative' privilege to survival servers which Ops can bestow on admin or competent builders to give access to the creative inventory.
@SmallJoker - thanks dude :) |
👍 |
@sfan5 - this is a very handy feature for survival servers and works really well, giving a use to minetest.is_creative(name)'s 'name' field. |
👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👎 a privilege should be the right to do something, not a state you're in.
Being able to use the creative inventory based on a privilege is okay, but it's not okay to have node digging modified. Note that an admin has all privileges, as they have the right to do anything.
I think that get/set_attributes would be a better candidate for changing a player's creative/survival mode.
@rubenwardy - I disagree, the creative priv will be granted to those trustworthy players on a survival server to allow them to build a lot easier with creative inventory and unlimited block placement. It is earned and definitely a privilege. |
👍 |
@Ezhh i read on IRC some dissatisfaction with MTG creative priv recently, please could you explain what you think is wrong with the MTG implementation? |
it changes the behaviour of the game, rather than giving you the right to do something. Either:
|
Oh just saw Ezhh was referring to MTG 'current stable', i read 'current' as meaning latest dev. |
Good idea, if someone has the creative priv they may sometimes find it irritating to be in creative mode due to how it affects inventory and crafting. |
I'm travelling, so not able to test what creative is like in current dev at the moment, but my preference would be for it to do nothing other than let you take items from creative inventory. You should otherwise be able to collect items or craft as you wish. (This way even if you have creative priv on a survival server, you can still choose to play as normal if you wish to.) I can't comment more than that until I know what current dev actually does. |
I think anyone you grant creative to should also have long interact distance and fast node dig too, otherwise having creative won't be very useful for them when they need to alter the world. I think anyone who is in 'creative mode' should have the full digging / placing / inventory abilities, and the priv should allow changing their gamemode to survival, as rubenwardy suggests. Then they will have both modes available instead of something halfway inbetween which does neither. Current master has tenplus1's creative priv added which puts the player into creative mode #1543 |
@paramat creative as I want it working certainly would not be considered "won't be very useful" by players or server owners, even without longer range / faster placement. Adding those automatically will make me less likely to give the priv to people because when I give someone creative on a survival server, I'm doing it so they have the variety of nodes to make a special building of some kind. (This is why it being a priv makes sense - it is giving the ability to use creative inventory). I'm not doing it to enable anything else and faster digging and so on is completely outside the scope of what I want. The problem my comments were based on is when creative is either not an option at all on survival, or when it interferes with your ability to pick up nodes. I've seen versions of creative where you are reduced to stacks of 1 no matter how many of a node you pick up,and that's terrible for all kinds of reasons. But as I said before, I'm travelling until the weekend so I can't test what MTG is doing to see if it's this. With all that said - it would be really nice if hand range was independently settable. This is something I have been wanting for a long time. Node removal range can already be adjusted by tools, but the hand is the hand, so placing is pretty limited. Even a separate setting for digging speed wouldn't be a bad thing, but please don't stack them all into survival mode creative without a lot more thought than this. |
Ezhh has asked we don't touch creative until next week when she can test it. So everyone be lazy for a few days. |
This adds a 'creative' privilege to survival servers which Ops can bestow on admin or competent builders to give access to creative features like the item inventory or continuous node placement.