Skip to content

Commit

Permalink
Added getWorldPermission function
Browse files Browse the repository at this point in the history
The new getWorldPermission function allows to check if the player is allowed to change settings or build in a world. It is pretty simple right now and only allows the direct owner of the world to do anything, but it can be enhanced later.

Using the function instead of directly checking for permissions, improvements can be made easily later. While the permissiontype parameter of the function does not anything yet, it will be used later to give specific permissions later on. Like giving build rights to specific users or interaction permissions.
  • Loading branch information
Abwasserrohr committed Jun 27, 2019
1 parent fffaf93 commit 662a322
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions STEEM.CRAFT/core/functions/permissions/getWorldPermission.sk
@@ -0,0 +1,26 @@
#
# ==============
# getWorldPermission.sk
# ==============
# getWorldPermission.sk is part of the STEEM.CRAFT core functions.
# ==============

#
# > Function - getWorldPermission
# > Returns if the player has permissions for this world.
# > Parameters:
# > <world>the world name
# > <player>the player who should get checked for permission
# > [<text>]the type of permission which should be checked (default="build")
# > [<boolean>]false = the player will not get a error message for not being allowed (default=true)
function getWorldPermission(world:world,player:player,permissiontype:text="build",senderror:boolean=true) :: boolean:
set {_steemaccount} to getSyncedAccount({_player})
#
# > Currently, there is no real permission system behind. If the name of
# > the world matches which the synced username, the user has permission
# > to edit the world.
if "%{_world}%" does not contain "steemworlds-%{_steemaccount}%-":
if {_senderror} is true:
message "%getChatPrefix()% You can only change the settings of your own worlds."
return false
return true

0 comments on commit 662a322

Please sign in to comment.