News:

Welcome to the new Sinister Design forums!

Main Menu

Trouble with arrays

Started by bugfartboy, June 03, 2015, 10:33:45 PM

Previous topic - Next topic

bugfartboy

Attempting to use the new array functionality that has been added, I've hit a few snags. I'm unsure if they're bugs or not, but using _ArrStr in a script tied to a ForArr action seems to do nothing.  From what I can tell from the log, it's not recognizing _ArrStr as a special character. (At least when used in the context of a SetString action.)  The scripts work just fine when the array is empty.  It's "ConcatenateString" that seems to have trouble.

The scripts in question being used, in case I'm just mangling something:

<Dialog branch="0" r="-1" name="Click">
    OnCharSelect//bugfartboy/A character on the map was selected. Let's see which one it was!
    <Action>Run/AddChar</Action>
    <Reply>.../EndConv/</Reply>
  </Dialog>
 
  <Script>
    ClearOutput
    <Action>DelArr/MBKChars,all</Action>
    <Action>Run/UpdateOutput</Action>
  </Script>
 
  <Script>
    UpdateOutput
    <Action>SetString/MBKOutput,</Action>
    <Action>ForArr/MBKChars,front,end,1,ConcatenateString</Action>
    <Action>AddTextOverlay/Entered Text: -STR:MBKOutput-</Action>
  </Script>
 
  <Script>
    ConcatenateString
    <Action>SetString/MBKOutput,-STR:MBKOutput-_ArrStr</Action>
  </Script>
 
  <Script>
AddChar
<Action>SetArr/MBKChars,end,-FNAME-</Action>
<Action>Run/UpdateOutput</Action>
  </Script>

(On an unrelated note, this is actually how I prefer to edit my dialog and scripts. The Dialog Editor is nice, but I like using Notepad++ and having a copy of the manual open instead.)

Log attached below.

CraigStern

The main problem I notice is that you're setting MBKOutput to the existing string plus "_ArrStr" rather than to the existing string with the special character -STR:_ArrStr- on the end. So the game is just producing strings like "_ArrStr_ArrStr_ArrStr" instead of concatenated strings consisting of the actual values contained within the _ArrStr variable.

(Also, probably unrelated: I notice that in your log, the game is trying to call the script "ConcatonateString." Is it misspelled somewhere?)

bugfartboy

I didn't realize that that the string needed put into tags like that... *facepalm*

Yeah, that's a typo that I fixed after the log was generated but before I posted the script. The name was spelled the same both places in the script.

Now that I've made myself feel foolish, locked.