RPG Starter

by Falacy
An Open Source Demo/Game with everything you'll need to get started on your very own BYOND Game!
ID:292228
 
    Ban()
set category="GM" //Puts the verb in the category "GM"
var/list/L=list() // Creates a list called L
for(var/mob/M in world) if(M.client) L+=M // Loops through every mob in the world, then if they are a player, it adds them to "L"
var/mob/M=input("Select Player to Ban","Ban Player") as null|anything in L // I don't understand this line
if(!M || !M.client || M==usr) return // This makes it so if you press cancel, or if you try to ban yourself it returns without doing anything
if(!BanList) BanList=list() // I don't understand this line
BanList+=M.key;BanList+=M.client.address // Adds your key and address to the BanList
world<<"[M] has been Banned by [usr]" // Outputs a message to the world
del M.client // Closes their window or something :P


Can someone explain the lines where i say "I don't understand" and tell me if i got the other correct?

I wanna learn what it does.
Exonit wrote:
> var/mob/M=input("Select Player to Ban","Ban Player") as null|anything in L // I don't understand this line

Asks the user to Input nothing or anything from the list L and save it to the mob variable M.
However we don't wanna get too much into this for beginners. This contains some binary arithmetic operanded by some byond internal flags.
if(!BanList)    BanList=list() // I don't understand this line


if BanList is a null or 0 or any false boolean(true/false) value then make it an empty list. This is done as precaution from certain runtime errors. (eg: if BanList is null and you do some list arithmetic with it then Baam! you got an error)
For instance:
Assume BanList=null and BanList += M.key would imply adding M.key to null (get the picture => null+=M.key) <--- Now that makes perfect nonsense (adding something to nothing?)
Now Assume BanList=list() and BanList+=M.key would imply adding M.key to an empty list (picture => list() += M.key) <--Now this makes prefect sense (adding something to an empty list)