Jump to content

OUTER_SPRINT %variable% = [string]


subtledoctor

Recommended Posts

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%~

Link to comment

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.)

Link to comment

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 by subtledoctor
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...