Posted by: Gob Oafenplug
« on: August 22, 2020, 12:10:18 PM »I suspect these are only useful to me; I'll list them in increasing order of presumed implausibility.
1) The ability to detect whether a given string actually names a function. At the moment I do it with TRY: run the function, if it doesn't run then catch the exception and return that it doesn't exist. But it's scarcely elegant.
If this is still under consideration, here's something I've been doing a whole lot of:
Code: [Select]
DEFINE_ACTION_FUNCTION MAKE_PRO STR_VAR bindTraceFn = ~~ resProVisualEffect = ~~ BEGIN
OUTER_TEXT_SPRINT bindTraceFn ~%bindTraceFn% MAKE_PRO->:~
OUTER_PATCH lots_of_functions_that_construct_a_projectile_such_as_the_below BEGIN
LPF setRefProVisualEffect STR_VAR bindTraceFn resProVisualEffect END
END
END
DEFINE_PATCH_FUNCTION setResProVisualEffect STR_VAR bindTraceFn = ~~ BEGIN
TEXT_SPRINT bindTraceFn ~%bindTraceFn% setResProVisualEffect->:~
LPF testResExists STR_VAR bindTraceFn res = EVAL~%refProVisualEffect%~ ext = BAM END
WRITE_ASCIIE 0x020 ~%refProVisualEffect%~ (8)
END
DEFINE_PATCH_FUNCTION testResExists STR_VAR bindTraceFn = ~~ BEGIN
TEXT_SPRINT bindTraceFn ~%bindTraceFn% testResExists->:~
PATCH_IF !FILE_EXISTS_IN_GAME ~%res%.%ext%~ BEGIN
PATCH_FAIL ~%bindTraceFn% no such file as %res%.%ext%~
END
END
LAF MAKE_PRO STR_VAR resProVisualEffect = SomeBamFile NED
for error handling and runtime type checking. If the fulfillment of DavidW's request were to expose function name as an automatic, implicit variable, this would remove some line noise from every function definition (at the obvious expense of transferring aforementioned line noise to the WeiDU source. )
If not, well, I've already implemented this the other way, so I'd have a compelling excuse not to change anything in code that already works.