Modified Autotext Tile

Bucket Mouse

Active member
As it is, the Autotext tile status works just once when you stand on it, and not again -- as it should. However, if you leave the screen, it will activate again.

There are times when you don't want it to do this. Therefore I've added something to it that responds to a trigger.

Code:
	CPX player1_object
	BNE finishedWithAutoText

	lda screenType ;; this is the value of the screen to change.
		AND #%00000111 ;; look at last bits to know what bit to check, 0-7
		TAX
		LDA ValToBitTable_inverse,x
		STA temp
	lda screenType
	
		LSR
		LSR
		LSR 
		;;; now we have the right *byte* out of the 32 needed for 256 screen bytes
		TAY
		LDA screenTriggers,y ;; now the rigth bit is loaded into the accum
		AND temp
		BNE finishedWithAutoText	

	JSR GetTileAtPosition
	LDA collisionTable,y		;<<-- check the current tile collision data
	BEQ finishedWithAutoText
	
	ChangeTileAtCollision #$00, underSecret  ;<<-- change the collision data of the current tile to null walkable and graphics to undersecret
	
	LDA #$01
	STA textBoxFlag
	JSR dodrawTextBox
	
finishedWithAutoText:

If you want to eliminate the text box effects from the screen permanently after one use, make your text set off a trigger. Now, when you return to the triggered screen, that text will no longer appear.

if you DON'T want this, just don't use a trigger on that screen. Or use the original unmodified version below:

Code:
CPX player1_object  ;; check if it is the player (not a monster)
	BNE finishedWithAutoText
	
	ChangeTileAtCollision #$00, underSecret
	LDA #$01
	STA textBoxFlag
	JSR dodrawTextBox
	
finishedWithAutoText:
	;;RTS
 

Bucket Mouse

Active member
I don't think we need a video. Take the script, copy it into Notepad and save it in GameEngineData/Routines/UserScripts/AdventureGame_Base/TileScripts as "Autotext.asm"

Then open NESmaker, go to Project Settings / Script settings and import the ASM, then use the "Change" button on the menu to assign it to one of the blank Tile Types.

Switch to the Project Labels tab and rename that Tile Type to "Autotext."

Now on any Overworld or Underworld screen, you can right-click and change the status of whatever tile you choose. Autotext will always bring up the first text in the assigned Text Group for that screen.
 

darkhog

New member
Hey, it doesn't work for me. And by doesn't work I mean game is stuck in infinite loop displaying the box over and over again.

//edit: Platform module, 4.0.11

//edit #2: Fixed it:

Code:
;; CHANGE to a "0 - Walkable" special Tile "UnderSecret"

	LDA screenType
		;; divide by 32
		LSR
		LSR
		LSR
		;LSR
		;LSR
		;;; now we have the right *byte* out of the 32 needed for 256 screen bytes
		TAY
		LDA screenTriggers,y ;; now the rigth bit is loaded into the accum
		STA temp
		LDA screenType
		AND #%00000111 ;; look at last bits to know what bit to check, 0-7
		TAX
		LDA ValToBitTable_inverse,x
		AND temp
		BNE finishedWithAutoText

	CPX player1_object  ;; check if it is the player (not a monster)
	BNE finishedWithAutoText
  JSR GetTileAtPosition
  LDA collisionTable,y
	BEQ finishedWithAutoText ;;already tripped.
	LDA #$01
	STA textBoxFlag
	JSR dodrawTextBox
  ChangeTileAtCollision #$00, underSecret
finishedWithAutoText:
	;;RTS

Checkpoint tile helped me.
 

Bucket Mouse

Active member
I'm on 4.0.6. What has to be changed specifically in the later build, and why?

(I'll probably be asking this again later this week when the next build hits...)
 

dale_coop

Moderator
Staff member
Agree with darhog, checking the tile (with the "GetTileAtPosition") before continuing, prevents a looping issue (got it too).
And I think you could clean up the code, for the triggering part, using a macro
Code:
  TriggerScreen screenType
 

darkhog

New member
Found another bug - if the monster walks into the tile, it activates anyway. Not sure how to fix that one though.
 

dale_coop

Moderator
Staff member
Try loving the lines:
Code:
    CPX player1_object  ;; check if it is the player (not a monster)
    BNE finishedWithAutoText
To the beginning of the script.
 

DanielT1985

Member
The "Only working once when in screen and refreshing screen making it work again" thing is actually gonna be useful for me. Thank you so much for creating this.
 

DanielT1985

Member
Oh, and also, I have an opening-text cutscene and had to use 2 screens because of another different text tile keeping me on loop if I don't get off of it, and the only way to do that was to have the player spawn on both at the same time, which also caused the beginning piece of dialogue to disappear. With this, I just spawn the person on the NPC tiles, they turn into background tiles, and the character falls onto the warp tiles AND keep the beginning piece of dialogue on the SAME screen. This actually saved me a screen.
 

darkhog

New member
dale_coop said:
Try loving the lines:
Code:
    CPX player1_object  ;; check if it is the player (not a monster)
    BNE finishedWithAutoText
To the beginning of the script.

That did the trick. I mean, loving these lines didn't work (even though I love them very much! :)), but moving them did. :) :) :)
 

Nintend0Nerd

New member
I'll just walk through what I did. I made the autotext.asm by copying and pasting the code into a notepad. I added to to the Project Settings > Scripts Settings by pressing add. I named it Tile Collision 15, Defined it as Tile_15, and wrote the path to the asm file in the scripts box. Then I went to Project Labels > Tile Types and renamed Null - Walkable 14 to 15 - Autotext.
 

Nintend0Nerd

New member
I started trying to put auto text from scratch again today and now instead of just compiling and not working, it's not compiling and giving me an error. For some reason, that feels like progress :D ! I've messed around a bit and can't get the error to resolve. The error is that Line 29 has a label already defined. It printed the error three times for some reason. Does anyone know how to resolve the problem?
 

Nintend0Nerd

New member
Routines\UserScripts\AdventureGame_Base\TileScripts\NullTile_Walkable.asm(29): Label already defined. NullTile_Walkable is what I overwrote.
 

dale_coop

Moderator
Staff member
You might have copied Passy an existing script, did you?
So you need to rename the label(s) in your script.
Because labels need to be uniques (for the whole project).
 

Nintend0Nerd

New member
Thanks! I got it to work! One quick question, when text boxes disappear in my game, it will sometimes leave some sprites discolored. It wasn't too big of a deal, since they just change when reloading the screen, but, in a boss fight room, it might get kind of distracting. Do you know why this occurs? I think they turn into the HUD's palette.
 
Can you change the text box in sprite sized increments (8 pixels)? If so, make it 1 sprite smaller or bigger so it aligns with the tiles. I think the wrong colors appear because the wrong palette gets used when the underlying tiles get redrawn.
 
Top Bottom