Jump to content

weidu 102 level question about a variable


Awachi

Recommended Posts

Goal is to read the # of the last row in the 2da.  Error is "weidu can't make song an integer" (and is on the second instance, not the read)

COPY_EXISTING songlist.2da override
	COUNT_2DA_ROWS 1 rows
		READ_2DA_ENTRY rows 1 1 song

COPY_EXISTING_REGEXP "^.*\.are$" override
	READ_LONG 0x00bc songoff
	WRITE_LONG (songoff + 0x0c) song
BUT_ONLY

 

Link to comment

%song% is a string. So I guess you need WRITE_ASCII.

EDIT - or rather WRITE_EVALUATED_ASCII.

EDIT 2 - or, not sure what you are actually trying to read. Remember that READ_2DA_ENTRY designates the first counted row or column as 0. SO if you are trying to get the index number in the first column, you would do

READ_2DA_ENTRY rows 0 1 song

Also  COUNT_2DA_ROWS gives you the actual number of rows, but when doing a READ or WRITE it again counts one as row 0. In this case because your column count is 1, %rows% matches up because it is counting the row with no valid data in it. ("     Name        RESOURCE") But it might not be best to include rows like that in your READ. If you are trying to get the value of the bottom-most index in the first column, if it was me, I would probably do this:

COPY_EXISTING songlist.2da override
    COUNT_2DA_COLS cols
    COUNT_2DA_ROWS cols rows
    READ_2DA_ENTRY (rows - 1) 0 cols song_num
BUT_ONLY

 

Edited by subtledoctor
Link to comment

Ah, so first entry is 0 and count from there.

Another pixel of width added to my progress bar.  😉

Edited by Awachi
Link to comment
7 hours ago, Awachi said:

Ah, so first entry is 0 and count from there.

Yeah but only in READ_ and SET_ commands. COUNT_2DA_ROWS starts from 1. So

COUNT_2DA_ROWS 3 rows

might give you a value of 20 in the %rows% variable; but a subsequent

READ_2DA_ENTRY rows 1 3 val

will error out because the last row number is 19. 

It can be annoying. 

Edited by subtledoctor
Link to comment
8 hours ago, subtledoctor said:

Yeah but only in READ_ and SET_ commands. COUNT_2DA_ROWS starts from 1. So

COUNT_2DA_ROWS 3 rows

might give you a value of 20 in the %rows% variable; but a subsequent

READ_2DA_ENTRY rows 1 3 val

will error out because the last row number is 19. 

It can be annoying. 

I met the same annoy-ness and thought I was an idiot... took a big chunk of me hair (pulling) to get it working eventually.🤣

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