Jump to content

A line of code that keeps giving wrong results


temnix

Recommended Posts

There is this line of code, which probably everyone uses to select NPC companions or not NPC companions in patching: PATCH_IF FILE_CONTAINS_EVALUATED (~pdialog.2da~ ~%deathvar%~), "deathvar" being the script name. For some reason this keeps returning true for creatures without a script name or with "None" there. Why?

Link to comment

Not sure - maybe the variable doesn't get properly populated in every instance?

Might save yourself some time and use code already developed by others:

Put the DEFINE_ACTION_MACRO in your ALWAYS block, and then any time you want to treat joinable or non-joinable NPCs, you just

LAM JOINABLE_NPC_ARRAYS
ACTION_PHP_EACH JOINABLE_NPC_ARRAY AS j_cre => dv BEGIN
  COPY_EXISTING ~%j_cre%~ ~override~
  //your patching code
END

or

LAM JOINABLE_NPC_ARRAYS
ACTION_PHP_EACH NON_JOINABLE_NPC_ARRAY AS n_j_cre => dv BEGIN
  COPY_EXISTING ~%n_j_cre%~ ~override~
  //your patching code
END

I think this has been pretty robust, as far as I've seen anyway.

Link to comment
3 minutes ago, Jarno Mikkola said:

This happens probably because the file table contains a space, and that equals to empty variable. It's not meant for usage with COPY_EXISTING_REGEXP GLOB ~*.cre~ ~override~ -commands.

I mean, there's no reason it can't be used that way.  Maybe need to tighten it up a bit - add a PATCH_IF (VARIABLE_IS_SET %deathvar%) here or there.  My suggestion was purely for the purpose of saving time/effort.

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