Jump to content
Sign in to follow this  

OUTER_SPRINT %variable% = [string]

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%~
    OUTER_SPRINT $this_kit_access(~%evaluated_variable%~) ~%kit_access%~
  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:

    OUTER_SPRINT s_Life ~%access%~

But it would be nice if I could just do something like:

  OUTER_SPRINT s_%variable% ~%access%~

Share this post

Link to post

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

Share this post

Link to post

without AUTO_EVAL_STRINGS I'm using following syntax:

OUTER_SPRINT EVAL ~s_%variable%~ ~%access%~


Share this post

Link to post

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.

Share this post

Link to post

How about something like:

ACTION_FOR_EACH array IN ~array1~ ~array2~ ~array3~ BEGIN
      ACTION_PHP_EACH EVAL %array% AS key => val BEGIN
        [array stuff]

    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

Share this post

Link to post
You are commenting as a guest. If you have an account, please sign in.
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.

Sign in to follow this