Merge pull request #1662 from TheDZD/proc-call

Allows use of marked objects/datums in proc call
This commit is contained in:
Fox-McCloud
2015-08-08 20:36:59 -04:00
+26 -8
View File
@@ -40,7 +40,12 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
switch(alert("Proc owned by something?",,"Yes","No"))
if("Yes")
targetselected = 1
class = input("Proc owned by...","Owner",null) as null|anything in list("Obj","Mob","Area or Turf","Client")
if(src.holder && src.holder.marked_datum)
class = input("Proc owned by...","Owner",null) as null|anything in list("Obj","Mob","Area or Turf","Client","Marked datum ([holder.marked_datum.type])")
if(class == "Marked datum ([holder.marked_datum.type])")
class = "Marked datum"
else
class = input("Proc owned by...","Owner",null) as null|anything in list("Obj","Mob","Area or Turf","Client")
switch(class)
if("Obj")
target = input("Enter target:","Target",usr) as obj in world
@@ -53,6 +58,8 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
for(var/client/C)
keys += C
target = input("Please, select a player!", "Selection", null, null) as null|anything in keys
if("Marked datum")
target = holder.marked_datum
else
return
if("No")
@@ -62,6 +69,10 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
var/procname = input("Proc path, eg: /proc/fake_blood","Path:", null) as text|null
if(!procname) return
if(targetselected && !hascall(target,procname))
usr << "<font color='red'>Error: callproc(): target has no such call [procname].</font>"
return
var/list/lst = get_callproc_args()
if(!lst)
return
@@ -70,9 +81,6 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
if(!target)
usr << "<font color='red'>Error: callproc(): owner of proc no longer exists.</font>"
return
if(!hascall(target,procname))
usr << "<font color='red'>Error: callproc(): target has no such call [procname].</font>"
return
log_admin("[key_name(src)] called [target]'s [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].")
returnval = call(target,procname)(arglist(lst)) // Pass the lst as an argument list to the proc
else
@@ -94,6 +102,10 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
if(!procname)
return
if(!hascall(A,procname))
usr << "<span class='warning'>Error: callproc_datum(): target has no such call [procname].</span>"
return
var/list/lst = get_callproc_args()
if(!lst)
return
@@ -101,9 +113,6 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
if(!A || !IsValidSrc(A))
usr << "<span class='warning'>Error: callproc_datum(): owner of proc no longer exists.</span>"
return
if(!hascall(A,procname))
usr << "<span class='warning'>Error: callproc_datum(): target has no such call [procname].</span>"
return
log_admin("[key_name(src)] called [A]'s [procname]() with [lst.len ? "the arguments [list2params(lst)]":"no arguments"].")
spawn()
@@ -122,8 +131,14 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
//this will protect us from a fair few errors ~Carn
while(argnum--)
var/class = null
// Make a list with each index containing one variable, to be given to the proc
var/class = input("What kind of variable?","Variable Type") in list("text","num","type","reference","mob reference","icon","file","client","mob's area","CANCEL")
if(src.holder && src.holder.marked_datum)
class = input("What kind of variable?","Variable Type") in list("text","num","type","reference","mob reference","icon","file","client","mob's area","Marked datum ([holder.marked_datum.type])","CANCEL")
if(holder.marked_datum && class == "Marked datum ([holder.marked_datum.type])")
class = "Marked datum"
else
class = input("What kind of variable?","Variable Type") in list("text","num","type","reference","mob reference","icon","file","client","mob's area","CANCEL")
switch(class)
if("CANCEL")
return null
@@ -158,6 +173,9 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that
if("mob's area")
var/mob/temp = input("Select mob", "Selection", usr) as mob in world
lst += temp.loc
if("Marked datum")
lst += holder.marked_datum
return lst
/client/proc/Cell()