Page 1 of 1

Passwords!

Posted: Fri Jun 08, 2012 2:46 am
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.

Posted: Fri Jun 08, 2012 3:05 am
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).

Posted: Fri Jun 08, 2012 3:17 am
by Master K
I checked, and it does display as 'BONUS'.

Posted: Fri Jun 08, 2012 3:53 am
by Mogri
Try changing the line from 4 $+ 3 to 4 $+ 2.

Posted: Fri Jun 08, 2012 6:32 am
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).