Jump to content

Photo

Changing Strings


  • Please log in to reply
5 replies to this topic

#1 Korben

Korben

    Junior

  • Members
  • Location:USA

Posted 21 February 2017 - 01:14 AM

Is there any way to change a screens string so that after you read the screens initial string it then changes to another string from then on? I know you can change strings using control codes and having it check if you have an item and then changing the string if you do, but I'd like to do it without giving the player an item. Thanks for reading.



#2 Russ

Russ

    Caelan, the Encouraging

  • Administrators
  • Location:Washington

Posted 21 February 2017 - 01:26 AM

ffc script PlayStringOnce{
	void run(int msg1, int msg2){
		if(Screen->D[0] != 1){
			Screen->D[0] = 1;
			Screen->Message(msg1);
			Waitframe();
		}
		else{
			Screen->Message(msg2);
			Waitframe();
		}
	}
}
Compile that script and put it on an FFC on the screen. In the arguments tab D0 is the string to play the first time you visit the screen, and D1 is the string to play on all other visits to the screen.

There are non-scripted workarounds to the problem, but most of them are far more complex than a simple script like this.
  • ShadowTiger likes this

#3 Omega

Omega

    Yes

  • Members

Posted 21 February 2017 - 06:14 AM

ffc script PlayStringOnce{
	void run(int msg1, int msg2){
		if(Screen->D[0] != 1){
			Screen->D[0] = 1;
			Screen->Message(msg1);
			Waitframe();
		}
		else{
			Screen->Message(msg2);
			Waitframe();
		}
	}
}
Compile that script and put it on an FFC on the screen. In the arguments tab D0 is the string to play the first time you visit the screen, and D1 is the string to play on all other visits to the screen.There are non-scripted workarounds to the problem, but most of them are far more complex than a simple script like this.
Would this work with an npc script?

#4 ywkls

ywkls

    Master

  • Members

Posted 21 February 2017 - 10:18 AM

Would this work with an npc script?

Sure, although there's aren't that many npc scripts that alter the Screen->D settings in this way on their own.

(My alternative NPC script in the database does in much that same way as the one which Russ provides, though it has some problems.)

 

I should note, for even simpler (or more complex) things, that String Control Codes can read the values set to a Screen->D register and alter themselves on their own with the need to code an extra message into the ffc. This is something I didn't know when I wrote my script, but which could be useful.



#5 Korben

Korben

    Junior

  • Members
  • Location:USA

Posted 23 February 2017 - 12:43 PM

ffc script PlayStringOnce{
	void run(int msg1, int msg2){
		if(Screen->D[0] != 1){
			Screen->D[0] = 1;
			Screen->Message(msg1);
			Waitframe();
		}
		else{
			Screen->Message(msg2);
			Waitframe();
		}
	}
}
Compile that script and put it on an FFC on the screen. In the arguments tab D0 is the string to play the first time you visit the screen, and D1 is the string to play on all other visits to the screen.

There are non-scripted workarounds to the problem, but most of them are far more complex than a simple script like this.

 

Thanks! I'll try it out.



#6 Aslion

Aslion

    End Fascism

  • Members
  • Real Name:Ryan
  • Location:Plug One's spectacles

Posted 23 February 2017 - 02:27 PM

If you don't want to use a different NPC script you can do it with string control codes too:

 

  • Create a dummy item and check 'Equipment Item'
  • Look at the ID of the dummy item
  • Use \16\(item id) in a string to give the player that item
  • Use \5\(item id)\(new string id) to have the game switch to playing the string with the number (new string id)

 

There are some disadvantages to this (you can only have so many items to do this with and need to do it once per string) so it might not work for you if you're doing this on a wide scale but it works like a charm without having to set up a different NPC script which might feel more inconsistent within your quest.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users