Autotext Tile in 4.1

dale_coop

Moderator
Staff member
I had some issues with the the npc_collision flag and textbox tiles / autotext tiles... personally, I decided to use my own variable to deal with that...

I declared a new "npc_autotext" user variable (or any name you want) in "Project Settings > User Variables".

Then I modified the AutoText.asm tile script to:
Code:
	CPX player1_object
	BNE finishedWithAutoText

	
	LDA tileCollisionFlag
	BEQ +
	JMP finishedWithAutoText
+	
	LDA #$01
	STA tileCollisionFlag
	
	STA npc_autotext	;; fix for the ">"more
	
	ChangeTileAtCollision #$00, underSecret  ;<<-- change the collision data of the current tile to null walkable and graphics to undersecret
	
	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler
	
	;TriggerScreen screenType
	
finishedWithAutoText:

Finally, modified the b_Activate_text_box.asm script, like that:
Code:
    LDA textboxHandler
    AND #%00010000 ;; if the b button is pressed
                    ;; but the box + text have been activated
                    ;; and also the 'do box' bit is OFF
                    ;; that means this is ready to "go away".
                    
    BEQ checkToTurnTheTextboxOn ;; hasn't started yet
    
    ;; begin turning the textbox off.
    LDA gameHandler
    ORA #%00100000
    STA gameHandler
    ;;; are we turning this on or off?
    ;;; check for more
    ;;; check for 'choice'.
  
    LDA #$00
    STA updateNT_offset
    STA updateNT_H_offset
    STA updateNT_V_offset
	
    STA npc_autotext	;;<-- dale_coop: for autotext tiles
    
    LDA #%10001000
    STA textboxHandler
    RTS
   
checkToTurnTheTextboxOn:  
	LDA npc_autotext	;;<-- dale_coop: for autotext tiles
	BEQ +
	JMP ++
+
    LDA npc_collision
    BEQ noNPCcollision
++
    LDA textboxHandler
    AND #%10000000
    BNE noNPCcollision
    LDA gameHandler
    ORA #%00100000
    STA gameHandler
    ;;; are we turning this on or off?
    ;;; check for more
    ;;; check for 'choice'.

turnTheTextboxOn:
  
    LDA #%10000000
    STA textboxHandler
    
noNPCcollision:
    RTS


It's not THE solution... it's a workaround.
 
BentPawGames said:
For some reason Dale's original code still doesn't work for me:

Code:
	CPX player1_object
	BNE finishedWithAutoText
	
	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
	
	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler
	
	;TriggerScreen screenType
	
finishedWithAutoText:

But then his other version does:

Code:
	CPX player1_object
	BNE finishedWithAutoText

	
	LDA tileCollisionFlag
	BEQ +
	JMP ++
+	
	LDA #$01
	STA tileCollisionFlag
	
	ChangeTileAtCollision #$00, underSecret  ;<<-- change the collision data of the current tile to null walkable and graphics to undersecret
	
	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler
	
	;TriggerScreen screenType
	
finishedWithAutoText:


However, while the text box comes up, I can't make it advance or go away by pressing the B button like I normally would. Not sure what is going on there.

I am having the same issue with the B button, though I am not using a tile. I am trying to automatically trigger textbox on specific powerup pickup or enemy action.
It just gets stuck after displaying the first part of the text.

I tried working in Dale's fix above for the > symbol but it didn't seem to work for me.

EDIT:
NVM I am a dummy, I modified the wrong file :\
It seems to work!
 
Update: If I cancel the text while it is loading by pressing the B button, then it goes away and I can move as normal. However, if I let all of the text load, then I am stuck and can't make the text box go away. Text otherwise has worked perfectly fine with NPCs.
 
Sorry, was just communicating what specifically wasn't working with the original code. Still need to try your most recent suggestion. I will be sure to though!
 
Hmm, so I tried the fix but not I just get a compiling error "label already defined" .

I am a bit out of practice so no I am trying to remember what the issue is with that. I don't know what is being defined by another script. I checked my B melee script and it doesn't handle text boxes.
 

dale_coop

Moderator
Staff member
Check with line the error corresponds.
Then search for the label in your script, maybe you have the label twice... also check in scripts > input scripts if you don't have more scripts than needed ;)
Also check you don't have duplicate variables in your Project Settings > User Variables.
 
Ok I found the stupid mistake: forgot that you can expand the input scripts to show the ones you have loaded even if they aren't used. For some reason I felt like I had to do that but couldn't remember how!
 

dale_coop

Moderator
Staff member
Ah ah ;) yep
All the scripts under the "Scripts > Input Scripts" are linked to your project... it means the code of all those scripts are in your game code.
It's important tho keep an eye on those (and make sure you don't have obsolete scripts, here).
 
Thanks!

So now a problem I am having is that when I walk into a room and trigger the autotext tile, it works as it should and reads the first bit of text in the text group but if I leave the room and come back, then it reads the second text in the text group. Any ideas on what that is happening?
 

dale_coop

Moderator
Staff member
A random value in the text id to display...
If you want to always display the 1st text of the text group, add
Code:
	LDA #$00  ;;<<-- it will use the "Text 1" of your screen
	STA textVar

In your script (maybe before the triggerScript line)
 

rimoJO

Member
Works great, but the game softlocks.
Code:
	CPX player1_object
	BNE finishedWithAutoText

	
	LDA tileCollisionFlag
	BEQ +
	JMP ++
+	
	LDA #$01
	STA tileCollisionFlag
	
	ChangeTileAtCollision #$00, underSecret  ;<<-- change the collision data of the current tile to null walkable and graphics to undersecret
	
	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler
	
	;TriggerScreen screenType
	
finishedWithAutoText:
 

baardbi

Well-known member
For some weird reason I can't get this to work. When I touch a text tile the screen slowly starts to change color, and something that looks like the start of a (empty) text box appears near the bottom of the screen. From what I can see, it looks like this is the source of the problem:

From text tile code:

Code:
	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler

Here is a little video of the problem:

textboxfail.gif


Here is the complete code for the text tile:

Code:
	CPX player1_object
	BNE finishedWithAutoText

	
	LDA tileCollisionFlag
	BEQ +
	JMP ++
+	
	LDA #$01
	STA tileCollisionFlag
	
	STA npc_autotext	;; fix for the ">"more
	
	ChangeTileAtCollision #$00, #$00  ;<<-- change the collision data of the current tile to null walkable and graphics to undersecret
	
	;; activate the text-box:
	LDA gameHandler
	ORA #%00100000
	STA gameHandler
	LDA #%10000000
	STA textboxHandler
	
	;TriggerScreen screenType
	
finishedWithAutoText:

Here is the Screen Info window for that particular screen:

textboxfail2.png


PS! Could the problem be that I have screwed something up in HandleTextBox.asm when I uncommented the hide/show sprites ...?
 

dale_coop

Moderator
Staff member
Try changing your
Code:
	JMP ++
For a
Code:
	JMP finishedWithAutoText

Also make sure you have correctly set your Textbox Area in the "Hud & boxes"

2020-03-19-11-11-16-HUD.png
 

baardbi

Well-known member
OMG! I don't believe it. I hadn't set the Textbox Area in the "Hud & boxes". I feel a little embarassed :oops: :D

Thank you very much for clearing up this little mistake :)
 

Jonny

Well-known member
Thanks Dale, works lovely.

Is there anyway to add this...

I would like to indicate who is talking during a text convo by having a small black triangular sprite drawn at the bottom of the textbox (making it look like a speech bubble).
My idea is that the graphic would toggle form the left to the right as the B button is pressed, giving the illusion of text coming from a different person.

My thoughts were to have more than one autotext.asm so that I could have one with the speech bubble toggle and one that worked as normal (for example during a monologue).

Any ideas how I would go about this? Or if its possible?

https://youtu.be/Xd5TyppL3Fk
 

baardbi

Well-known member
Has anyone got the AutoText tile to work in 4.5.6? I'm making a metroidvania game and I can't get the tile to trigger display of the text. I don't remember seeing this in any of the tutorials. Am I missing something?
 
Top Bottom