From bf921c635f946fa1509d27117ff9baf3c228a3d3 Mon Sep 17 00:00:00 2001 From: Lzimann Date: Fri, 10 Feb 2017 16:40:28 -0200 Subject: [PATCH 1/3] Allows in-game proccalls to have named arguments --- code/modules/admin/verbs/debug.dm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index cfe320c4074..8d8862ad5d5 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -118,16 +118,17 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that if(isnull(argnum)) return - var/list/lst = list() - + . = list() + var/arg_position = 1 while(argnum--) + var/named_arg = input("Position[arg_position++]. Leave blank for positional argument", "Named argument") as text|null var/value = vv_get_value(restricted_classes = list(VV_RESTORE_DEFAULT)) if (!value["class"]) return - lst += value["value"] - - return lst - + if(named_arg) + .[named_arg] = value["value"] + else + . += value["value"] /client/proc/get_callproc_returnval(returnval,procname) . = "" From 2ea2c445049b5644e5925a5e0a41a938de95f2b6 Mon Sep 17 00:00:00 2001 From: Lzimann Date: Fri, 10 Feb 2017 20:31:17 -0200 Subject: [PATCH 2/3] Removes positional var --- code/modules/admin/verbs/debug.dm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 8d8862ad5d5..8ca198e66e0 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -119,9 +119,8 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that return . = list() - var/arg_position = 1 while(argnum--) - var/named_arg = input("Position[arg_position++]. Leave blank for positional argument", "Named argument") as text|null + var/named_arg = input("Leave blank for positional argument(it won't work if you put AFTER putting a named arg)", "Named argument") as text|null var/value = vv_get_value(restricted_classes = list(VV_RESTORE_DEFAULT)) if (!value["class"]) return From db19d6b2d010589e929a4e0db857ad8be1fc77d5 Mon Sep 17 00:00:00 2001 From: Lzimann Date: Sat, 11 Feb 2017 02:14:01 -0200 Subject: [PATCH 3/3] Named args will now go to the end of the list --- code/modules/admin/verbs/debug.dm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/modules/admin/verbs/debug.dm b/code/modules/admin/verbs/debug.dm index 8ca198e66e0..b7672484554 100644 --- a/code/modules/admin/verbs/debug.dm +++ b/code/modules/admin/verbs/debug.dm @@ -119,15 +119,18 @@ But you can call procs that are of type /mob/living/carbon/human/proc/ for that return . = list() + var/list/named_args = list() while(argnum--) - var/named_arg = input("Leave blank for positional argument(it won't work if you put AFTER putting a named arg)", "Named argument") as text|null + var/named_arg = input("Leave blank for positional argument. Positional arguments will be considered as if they were added first.", "Named argument") as text|null var/value = vv_get_value(restricted_classes = list(VV_RESTORE_DEFAULT)) if (!value["class"]) return if(named_arg) - .[named_arg] = value["value"] + named_args[named_arg] = value["value"] else . += value["value"] + if(LAZYLEN(named_args)) + . += named_args /client/proc/get_callproc_returnval(returnval,procname) . = ""