subtledoctor Posted February 11, 2019 Share Posted February 11, 2019 OR OUTER_SET %variable% = [value] Possible? So far I have something like this: DEFINE_ACTION_MACRO set_sphere_access_variables BEGIN ACTION_PHP_EACH kit_spheres AS this_variable => kit_access BEGIN OUTER_INNER_PATCH_SAVE evaluated_variable ~%this_variable%~ BEGIN PHP_EACH sphere_name_changes AS fnp_sphere => new_sphere BEGIN REPLACE_TEXTUALLY ~%new_sphere%~ ~%fnp_sphere%~ END END OUTER_SPRINT $this_kit_access(~%evaluated_variable%~) ~%kit_access%~ END ACTION_CLEAR_ARRAY kit_spheres ACTION_PHP_EACH this_kit_access AS variable => access BEGIN ... There are 44 variables I have to define, so I could repeat this 44 times: ACTION_IF (~%variable%~ STRING_EQUAL_CASE ~Life~) BEGIN OUTER_SPRINT s_Life ~%access%~ END But it would be nice if I could just do something like: OUTER_SPRINT s_%variable% ~%access%~ Quote Link to comment
DavidW Posted February 11, 2019 Share Posted February 11, 2019 WEIDU is generally fine with this kind of thing. You need quotation marks around the variable name (s_%variable% is probably no good, "s_%variable%" is good); it helps to declare AUTO_EVAL_STRINGS in the preamble, and sometimes you need the occasional EVAL even so, but basically everything should work. (I do this kind of thing all the time.) Quote Link to comment
K4thos Posted February 11, 2019 Share Posted February 11, 2019 without AUTO_EVAL_STRINGS I'm using following syntax: OUTER_SPRINT EVAL ~s_%variable%~ ~%access%~ Quote Link to comment
subtledoctor Posted February 11, 2019 Author Share Posted February 11, 2019 Huh. I swear I tried SPRINT EVAL once a long time ago and it failed, so I concluded it could not be done. I guess it must have been a different problem. Cool, I'll play around with this. Quote Link to comment
subtledoctor Posted February 11, 2019 Author Share Posted February 11, 2019 (edited) How about something like: ACTION_FOR_EACH array IN ~array1~ ~array2~ ~array3~ BEGIN ACTION_PHP_EACH EVAL %array% AS key => val BEGIN [array stuff] END END More context: the mod will have an array specifying ~40 keys/values for ~100 different kits, and I want to determine those values and pass them as variables into a function. The function already has a variable for %clab_name% so it would be ideal to simply name each array as "CLABFI01_array" "CLABPR01_array" etc., and then put this in a function: ACTION_PHP_EACH EVAL %clab_name%_array AS this_variable => kit_access BEGIN I'm getting parse errors so I assume it doesn't work... EDIT - it does work! Just need quotes around the array name: ACTION_PHP_EACH EVAL ~%clab_name%_array~ AS this_variable => kit_access BEGIN Edited February 11, 2019 by subtledoctor Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.