Passwords!

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
Master K
King Slime
Posts: 1899
Joined: Sat Jun 11, 2011 9:40 pm
Location: A windswept rock in the Atlantic Ocean

Passwords!

Post by Master K »

I need help making a passworded box.

Code: Select all

plotscript, newgame password, begin
	time loop := false
	suspend player
	
	$3 = "BONUS"
	input string(2,5)
	
	if (string compare(2,3) == true) then (
	show text box(278)
	wait for text box
	
	)
	
	show text box(277)
	wait for text box
	resume player
	time loop := true
	end
It compiles, but the string is permanently stuck on screen and the string compare won't come up true.
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

That the string isn't hidden after "input string" is actually a bug that's fixed in currently nightlies. You can just add "hide string (2)" after it as a workaround.

I don't know why the string doesn't compare as equal. You can try adding

Code: Select all

$4="'"
4 $+ 3
$4+"'"
show string(4)
after "input string" to cause it to show entered password in the bottom corner of the screen. Then you can check that the string you entered actually registered displays as 'BONUS' (with the apostrophes, but without any extra whitespace or anything).
Last edited by TMC on Fri Jun 08, 2012 3:07 am, edited 1 time in total.
User avatar
Master K
King Slime
Posts: 1899
Joined: Sat Jun 11, 2011 9:40 pm
Location: A windswept rock in the Atlantic Ocean

Post by Master K »

I checked, and it does display as 'BONUS'.
User avatar
Mogri
Super Slime
Posts: 4598
Joined: Mon Oct 15, 2007 6:38 pm
Location: Austin, TX
Contact:

Post by Mogri »

Try changing the line from 4 $+ 3 to 4 $+ 2.
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Oh! I just remembered another bug that's been fixed in Alectormancy: stringcompare used to return -1 instead of 1 on equality. As a workaround, get rid of the "== true". It's bad practice to write that anyway (partially because there may be more commands with that bug -- we never checked all of them -- and partially because a command might be documented to return some other value without you realising).
Last edited by TMC on Fri Jun 08, 2012 6:34 am, edited 1 time in total.
Post Reply