Skip to content

Commit

Permalink
Updated/fixed The doc strings.
Browse files Browse the repository at this point in the history
  • Loading branch information
chris0076 committed Jun 6, 2011
1 parent 1ac714a commit c7e1438
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 37 deletions.
3 changes: 3 additions & 0 deletions src/pyscripts/editing/base.py
Expand Up @@ -45,6 +45,7 @@ def stop(self):
@CSCommand("clearpackets","admin")
@eventHandler('no_clients')
def stopSendingPackets(caller=None):
'''Clears all of the packets from the queue.'''
packetSendingQueue.stop()

def packettypename(number):
Expand All @@ -58,6 +59,7 @@ def packettypenumber(name):

@CSCommand("sendpacket","admin")
def sendpacket(caller,*args):
'''Sends the specified packet from the server.'''
if len(args)==0:
return
packettype=packettypes[packettypenumber(args[0])]
Expand All @@ -72,6 +74,7 @@ def noticeEditPacket(cn,packettype,*data):

@CSCommand("newmap","trusted")
def newmap(caller,size):
'''Starts a newmap. Includes an arg for the map size.'''
size=int(size)
if size<10:
size=10
Expand Down
6 changes: 5 additions & 1 deletion src/pyscripts/editing/cubes.py
Expand Up @@ -9,6 +9,7 @@

@CSCommand("editf","trusted")
def editfcommand(caller,*args):
'''Sends an editf packet with the given args.'''
editf(*map(int,args))

def editf(*args):
Expand All @@ -18,6 +19,7 @@ def editf(*args):

@CSCommand("makecube","trusted")
def makecube(caller,x,y,z,s=16):
'''Makes a single cube at the specified location and of the repective size.'''
s=int(s)
x=int(x)*s
y=int(y)*s
Expand All @@ -26,6 +28,7 @@ def makecube(caller,x,y,z,s=16):

@CSCommand("makecolumn","trusted")
def makecolumn(caller,x,y,z=0,h=16,s=16):
'''Creates a clumn of cubes at an x, y coordinate.'''
s=int(s)
h=int(h)
x=int(x)*s
Expand All @@ -35,6 +38,7 @@ def makecolumn(caller,x,y,z=0,h=16,s=16):

@CSCommand("corners","trusted")
def cornerscommand(caller,x,y,z,c0,c1,c2,c3,s=16):
'''Pushes the top 4 corners of the cube at the given coordinate.'''
s=int(s)

x=int(x)
Expand All @@ -54,4 +58,4 @@ def corners(x,y,z,cornerslist,s=16):
z=z*s
for index,depth in enumerate(cornerslist):
if depth!=0:
editf(x,y,z,1,1,1,s,5,(index%2),1,(index/2),1,1,depth,0)
editf(x,y,z,1,1,1,s,5,(index%2),1,(index/2),1,1,depth,0)
4 changes: 3 additions & 1 deletion src/pyscripts/editing/image.py
Expand Up @@ -15,6 +15,7 @@
@CSCommand("loadimage1","trusted")
@threaded
def loadimage1(caller,imagename,s=16,maxh=20):
'''Loads an image and starts the process of converting a heightmap into cube packets for map generation(blocky).'''
s=int(s)
(xsize, ysize, heights)=loadheightmap(imagename,int(maxh))

Expand All @@ -32,6 +33,7 @@ def loadimage1(caller,imagename,s=16,maxh=20):
@CSCommand("loadimage2","trusted")
@threaded
def loadimage2(caller,imagename,s=16,maxh=20):
'''Loads an image and starts the process of converting a heightmap into cube packets for map generation(smooth).'''
s=int(s)
(xsize, ysize, heights)=loadheightmap(imagename,int(maxh)*8)

Expand All @@ -58,4 +60,4 @@ def loadheightmap(imagename,maxh):
heights.append([])
for x in xrange(xsize):
heights[y].append(sum(pixels[x,y])*maxh/256/3)
return xsize, ysize, heights
return xsize, ysize, heights
4 changes: 2 additions & 2 deletions src/pyscripts/hyperserv/clientcommands.py
Expand Up @@ -86,13 +86,13 @@ def simpleMasterRequest(caller):
raise PermissionError("There are masters/admins present.")

def setSimpleMaster(caller):
"""sets the caller a simple master, just like /setmaster 1 does it on a vanilla server"""
"""Sets the caller a simple master, just like /setmaster 1 does it on a vanilla server"""
UserSessionManager[caller]=("notloggedin","master")
playerCS.executeby(caller,"master")

@CSCommand("givemaster","master")
def giveMaster(caller,cn):
"""This command gives master to the cn designated. This will raise an error if the player already has permssions at, or beyond, master."""
"""Gives master to the cn designated. This will raise an error if the player already has permssions at, or beyond, master."""
target=("ingame",int(cn))
if UserSessionManager[target][0]=="notloggedin":
setSimpleMaster(target)
Expand Down
2 changes: 1 addition & 1 deletion src/pyscripts/hyperserv/notices.py
Expand Up @@ -13,7 +13,7 @@ def serverNotice(string):

@CSCommand("notice","admin")
def CSserverNotice(caller, *strings):
"""This allows the caller to make a server notice at the top of the screen of all of the players."""
"""Allows the caller to make a server notice for all players in the server to see."""
string=' '.join(strings)
if caller[0]=="system":
serverNotice(string)
Expand Down
44 changes: 22 additions & 22 deletions src/pyscripts/hyperserv/servercommands.py
Expand Up @@ -19,14 +19,14 @@ class ServerError(Exception): pass

@CSCommand("vote")
def voteMap(caller,name,mode=None):
"""This command works just like the #map command except rather than directly going to a map it places a vote for the map of choice. Just like with #map, the caller can also call maps from /storage/maps. This calls the map from the server removing the need to /sendmap (as long as the maps are the same version)."""
"""Places a vote for the map of choice. This can be used to call maps from /storage/maps."""
if mode is None:
mode=sbserver.gameMode()
triggerServerEvent("vote_map",[caller,modeNumber(mode),name])

@CSCommand("map","master")
def changeMap(caller,name,mode=None):
"""This command works just like the /map command except for with #map the caller can also call maps from /storage/maps. This calls the map from the server removing the need to /sendmap (as long as the maps are the same version). """
"""Same as the /map command."""
if mode is None:
mode=sbserver.gameMode()
mode=modeNumber(mode)
Expand All @@ -44,31 +44,31 @@ def changeMap(caller,name,mode=None):

@CSCommand("master","master")
def setMaster(caller):
"""This command makes the caller the master of the server. This is denoted by the green color of the callers name. Also like with #admin it does not give the caller any powers beyond what the caller had before."""
"""Makes the caller the master of the server."""
if(caller[0]=="ingame"):
return sbserver.setMaster(caller[1])
raise ServerError("You are not ingame.")
return

@CSCommand("admin","admin")
def setAdmin(caller):
"""Makes the caller the admin of the server. This is denoted by the gold color of their name. Note that this is just for show because it does not give the user any more powers."""
"""Makes the caller the admin of the server."""
if(caller[0]=="ingame"):
return sbserver.setAdmin(caller[1])
raise ServerError("You are not ingame.")
return

@CSCommand("relinquish")
def relinquish(caller):
"""This command gives up the level of power that the player has (master or admin)."""
"""Gives up the level of power that the player has (master or admin)."""
if(caller[0]=="ingame"):
return sbserver.resetPrivilege(caller[1])
raise ServerError("You are not ingame.")
return

@CSCommand("kick","master")
def kick(caller,cn):
"""This allows the caller to kick another player; however, this will not override players with higher permission. Meaning, a master level permission can not kick someone with admin or trusted permission. To prevent the player from rejoining the server, they will also be banned for the default 60 minutes."""
"""Kicks another player; however, this command does not work on players with higher permission. Kicking a player also gives them a 60 minute ban."""
cn=int(cn)
UserSessionManager.checkPermissions(caller,UserSessionManager[("ingame",cn)][1]) #check if the other person is more privileged

Expand All @@ -78,13 +78,13 @@ def kick(caller,cn):

@CSCommand("sendto","master")
def sendto(caller,cn):
"""This command forces the specified player to /getmap. This is useful when a player is not paying attention, AFK or, for extension, if the caller wanted everyone to getmap."""
"""Forces the specified player to /getmap."""
cn=int(cn)
return sbserver.sendMapTo(cn)

@CSCommand("spectator")
def spectator(caller,boolean=None,cn=None):
"""If there are no arguments other than #spectator then the caller will be set to spectator. The first argument is a boolen that says what state of spectating the player will be (0 for not not a spectator and 1 for spectator), anything other than 0 will result in an them being a spectator. The cn is the client number of the player that the caller want spectated. If left off it will apply to the caller."""
"""Sets spectator for the given cn. If the cn is left of it applies to the caller."""
#empty args
if boolean is None:
boolean=1
Expand Down Expand Up @@ -114,7 +114,7 @@ def spectatorHelpler(boolean,cn):

@CSCommand("editmute","master")
def editmute(caller,boolean=None,cn=None):
"""If there are no arguments other than #editmute then the caller will be editmuted. The first argument is a boolen that says what state of editmuted the player will be (0 for not editmuted and 1 for editmuted), anything other than 0 will result in an editmute. The cn is the client number of the player that the caller want editmuted. If left off it will apply to the caller."""
"""Sets an editmute on the given cn. If the cn is left of it applies to the caller."""
#empty args
if boolean is None:
boolean=1
Expand All @@ -137,7 +137,7 @@ def editmute(caller,boolean=None,cn=None):

@CSCommand("mastermode","master")
def masterMode(caller,name=None):
"""This changes the mastermode in the same way that /mastermode does without the need to have claimed master or admin."""
"""Changes the mastermode of the server."""
if name==None:
return sbserver.masterMode()
mastermode=mastermodeNumber(name)
Expand All @@ -153,7 +153,7 @@ def masterMode(caller,name=None):

@CSCommand("who")
def who(caller,where="ingame"):
"""This gives info on all the people logged in to the server. It tells their name, client number and IP address. Use this in conjuction with #echo. Ex: #echo (who)"""
"""Gives info on all the people logged in to the server. This includes: name, cn and IP address. Use this in conjuction with #echo. Ex: #echo (who)"""
def cndetails(cn):
return sbserver.playerName(cn)+" (cn"+str(cn)+"/"+ipLongToString(sbserver.playerIpLong(cn))+")"

Expand All @@ -169,7 +169,7 @@ def cndetails(cn):

@CSCommand("list")
def listCommands(caller,which="hyperserv"):
"""List all commands available. Use this in conjuction with #echo. Ex: #echo (list)"""
"""Lists all commands available. Use this in conjuction with #echo. Ex: #echo (list)"""
if which=="all":
commands=systemCS.functions.keys()+systemCS.external.keys()
elif which=="cubescript":
Expand All @@ -181,21 +181,21 @@ def listCommands(caller,which="hyperserv"):

@CSCommand("say","admin")
def say(caller,*what):
"""This commad says string to the server, simialar to #notice, just without the Notice from PlayerName: MESSAGE HERE"""
"""Causes the server to say the input, simialar to #notice, without "Notice from PlayerName: MESSAGE HERE""""
string=' '.join(map(str,what))
triggerServerEvent("say",[string])
return string

@CSCommand("echo")
def echo(caller,*what):
"""This is how the caller can read the output from some commands. Examples: listusersessions, list, user, who, whoami. Note that the command must be in parentheses. #echo (command)"""
"""Displays the output from commands. Examples: listusersessions, list, user, who, whoami. Note that the command must be in parentheses. #echo (command)"""
string=' '.join(map(str,what))
triggerServerEvent("echo",[caller,string])
return string

@CSCommand("ban","trusted")
def ban(caller,who=None,reason="",time="60"):
"""This bans the person specified. If there is not a name given then the caller will be banned. If time is "perm","permanent","permanently","0" or 0 then the ban will be permanent. The default ban time is 60 minutes."""
"""Bans the person specified. If there is not a name given then the caller will be banned. If time is "perm","permanent","permanently","0" or 0 then the ban will be permanent. The default ban time is 60 minutes."""
if who is None:
bans(caller)

Expand All @@ -216,25 +216,25 @@ def ban(caller,who=None,reason="",time="60"):

@CSCommand("bans","master")
def bans(caller):
"""This returns all of the current bans in effect. Use this in conjuction with #echo. Ex: #echo (bans)"""
"""Returns all of the current bans in effect. Use this in conjuction with #echo. Ex: #echo (bans)"""
return bandatabase

@CSCommand("delban","trusted")
def delban(caller,who):
"""This deletes a username from the database."""
"""Deletes a username from the ban database."""
del bandatabase[who]

@CSCommand("minsleft")
def minsleft(caller,time=None):
"""This sets the amount of time remianing on the map. This can only be used when the mapmode is not Coopedit"""
"""Sets the amount of time remianing on the map. This can also be used in conjuction with #echo. Ex: #echo (minsleft)"""
if time is not None:
UserSessionManager.checkPermissions(caller,"trusted")
sbserver.setMinsRemaining(int(time))
return sbserver.minutesRemaining()/60 #todo, fix the api, it shouldn't return seconds...

@CSCommand("team")
def team(caller,*args):
"""This allows players to switch teams just like with /team."""
"""Allows players to switch teams just like with /team."""
if(len(args)==1):
if(caller[0]=="ingame"):
cn=caller[1]
Expand All @@ -256,7 +256,7 @@ def team(caller,*args):

@CSCommand("mute","master")
def mute(caller,*args):
"""If there are no arguments other than #mute then the caller will be muted. The first argument is a boolen that says what state of muted the player will be (0 for not muted and 1 for muted), anything other than 0 will result in an mute. The cn is the client number of the player that caller want muted. If left off it will apply to the caller."""
"""Sets a mute on the given cn. If the cn is left of it applies to the caller."""
if(len(args)==1):
boolean=1
cn=args[0]
Expand All @@ -272,7 +272,7 @@ def mute(caller,*args):

@CSCommand("savemap","trusted")
def savemap(caller,name=None):
"""This allows players to savemaps to the server. This not only allows for easier transfer of files later on, but also allows for partial asynchronous work on a map by saving the map back to the server."""
"""Saves the map to the server. Note that the map must be sent prior to saving."""
if name is None:
name=sbserver.mapName()
ogzfilename,ogz=openfile(os.path.join("maps",name+".ogz"),"wb")
Expand All @@ -286,7 +286,7 @@ def savemap(caller,name=None):

@CSCommand("loadmap","master")
def loadmap(caller,name=None):
"""This is the opposite of #savemap. This is automatically executed when you change to a map that the server has in storage."""
"""Loads a map from the server. This is automatically executed when you change to a map that the server has in storage."""
if name is None:
name=sbserver.mapName()

Expand Down
5 changes: 4 additions & 1 deletion src/pyscripts/hypershade/config.py
Expand Up @@ -16,17 +16,20 @@ def __str__(self):

@CSCommand("writecfg","admin")
def writecfg(caller):
"""Prints out all of the .cfg files associated with the server."""
print "//writecfg by %s.\n%s" % (caller, config)

@CSCommand("cfg","admin")
def cfgEntry(caller,key,*values):
"""Changes a value in the .cfg."""
if len(values)>0:
config[key]=' '.join(values)
return config[key]

@CSCommand("cfgdel","admin")
def delEntry(caller,key):
"""Deletes a value from the .cfg. """
return config.pop(key)

systemCS.executestring(open("../../config.cfg","r").read())
print "Configuration loaded."
print "Configuration loaded."
5 changes: 4 additions & 1 deletion src/pyscripts/hypershade/files.py
Expand Up @@ -22,13 +22,15 @@ def openfile(filename,mode="rb"):

@CSCommand("listfiles")
def listfiles(caller,folder="."):
"""Lists all the files in the given folder. Use this in conjuction with #echo. Ex: #echo (listfiles)"""
filelist=glob.glob(safepath(config["storage"],os.path.join(folder,"*")))
filelist=map(lambda absolute:os.path.split(absolute)[1],filelist)
return ' '.join(filelist)

@CSCommand("downloadfile","trusted")
@threaded
def downloadfile(caller,address,filename=None):
"""Downloads the specified file to the server."""
if filename is None:
filename=posixpath.split(address)[-1]
source=urllib2.urlopen(address)
Expand All @@ -39,6 +41,7 @@ def downloadfile(caller,address,filename=None):

@CSCommand("deletefile","admin")
def deletefile(caller,filename):
"""Deletes the specified file from the server."""
filename=safepath(config["storage"],filename)
os.remove(filename)
serverNotice("Deleted %s" % (filename,))
serverNotice("Deleted %s" % (filename,))

0 comments on commit c7e1438

Please sign in to comment.