Jump to content

Adding stuff to top/middle of .BCS files


Recommended Posts

I have an invisicreature .BCS script that looks like:

IF
  True(A)
THEN
  RESPONSE #100
  [ACTION 1]
  Continue()
END

IF
  True(B)
THEN
  RESPONSE #100
  [ACTION 2]
  Continue()
END

IF
  True()
THEN
  RESPONSE #100
  DesrtoySelf()
END

Now, say I come along later and I want to add more conditions to the script.  My new condition is in a .BAF file like:

IF
  True(C)
THEN
  RESPONSE #100
  [ACTION 3]
  Continue()
END

Seems like the way to fold this into the existing script is:

COMPILE ~mymod/scripts/nuscript.baf~
EXTEND_TOP ~override/script.bcs~ ~override/nuscript.bcs~

My only issue is, this needlessly pollutes the override folder with nuscript.bcs, which has no purpose other than to be prepended to script.bcs.  I would prefer to DECOMPILE_AND_PATCH and simply inject the text... but there is no APPEND_TOP command for adding text to the beginning of a file.

Is there a better way to do this?

Link to comment

You can insert the .baf text as a inlined action... like so in the weidu-readme:

BEGIN ~MyMod Component 1~

<<<<<<<< .../mymod-inlined/myfile.baf
IF
  True()
THEN
  RESPONSE #100
    Kill("Anomen")
END
>>>>>>>>

COMPILE ~.../mymod-inlined/myfile.baf~

Easy.

Edited by Jarno Mikkola
Link to comment
    COPY - ~mymod/scripts/nuscript.baf~ override
        SET length = SOURCE_SIZE
        READ_ASCII 0 nuscript (length)
    COPY_EXISTING ~script.bcs~ override
        DECOMPILE_AND_PATCH BEGIN
            INSERT_BYTES 0 length
            WRITE_ASCIIE 0 ~%nuscript%~ (length)
            EVALUATE_BUFFER // if you have any variables in nuscript.baf
        END
    BUT_ONLY

 

Link to comment

A single call of

EXTEND_TOP ~script.bcs~ ~mymod/scripts/nuscript.baf~ EVAL

should be enough.

EXTEND_[TOP|BOTTOM] automatically fetches the game script from BIFF or override (and even creates a new SCRIPT.BCS if it doesn't exist yet), compiles the .BAF and extends the game script. EVAL can be omitted if you don't need to evaluate variables in the .BAF.

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