ID:2725962
 
//This will hold the name of the empty argument
/var/badargstring = ""

//This is required so we can trigger a runtime without a compile error.
/dummydatum/var/Required_Argument

//so, the idea is to specify a default value to an argument that triggers a runtime, as the default value expression is only parsed when that argument is passed as null, or not passed at all.
// we can't use crash or throw here, as byond understands they have no return value, so it will only let you use them as statements, not in expressions.
// so we instead just trigger a cannot read error as part of our expression
#define req(argument) argument = ((badargstring = #argument) && badargstring:Required_Argument)

/proc/testthing()
world.log << testreq(1)
world.log << testreq()

/proc/testreq(req(inputnum), second_inputnum)
return "got called with [json_encode(inputnum)] and [json_encode(second_inputnum)]"


Result

got called with 1 and null
runtime error: Cannot read "inputnum".Required_Argument
proc name: testreq (/proc/testreq)
usr: (src)
src: null
call stack:
testreq(null, null)
Improved version with a better message and no dangling variables/datums

#define req(argument) argument = (#argument^"Argument is required")
/proc/testthing()
world.log << testreq(1)
world.log << testreq()

/proc/testreq(req(inputnum), second_inputnum)
return "got called with [json_encode(inputnum)] and [json_encode(second_inputnum)]"


Result

got called with 1 and null
runtime error: type mismatch: "inputnum" ^ "Argument is required"
proc name: testreq (/proc/testreq)
usr: (src)
src: null
call stack:
testreq(null, null)
main()