WeiDUorg / weidu

WeiDU is a program used to develop, distribute and install modifications for games based on the Infinity Engine.
http://www.weidu.org
GNU General Public License v2.0
87 stars 19 forks source link

Cannot copy array defined by READ_2DA_ENTRIES_NOW #221

Closed SarahG-579462 closed 9 months ago

SarahG-579462 commented 1 year ago

the following snippet doesn't set the array outtable `

  DEFINE_ACTION_FUNCTION 2DA_TO_ASARRAY 
    STR_VAR filename = ~~
            fileto = ~override~
    RET_ARRAY
      outtable
    BEGIN 
      COPY_EXISTING "%filename%" "%fileto%"
        COUNT_2DA_COLS "ncols"
        READ_2DA_ENTRIES_NOW "outtable" "%ncols%"
        BUT_ONLY
  END

`

I suspect this is because READ_2DA_ENTRIES_NOW also sets the variable %outtable% = number of 2da rows.

SarahG-579462 commented 1 year ago

temporary (dumb) solution: `

 FOR (row=0; row < "%nrows%"; row += 1) BEGIN
    FOR (col=0; col < "%ncols%"; col += 1) BEGIN
      READ_2DA_ENTRY_FORMER "outtable" "%row%" "%col%" tmp
      SPRINT $outtable2("%row%" "%col%") "%tmp%"
    END
  END

`

FredrikLindgren commented 9 months ago

Done in 09e78b5acf9f0e6e04ac3d5bc94a453fd650281a.