Essentials Docs Wiki
All Contributors
ShinyTogedemaru
• 9/30/2018

Password inputting script not recognising input password

Oh, how I hate when things delete themselves after leaving a page. So anyway, on the old wiki, there was a tutorial for inputting a password. It was not deprecated. The tutorial is nowhere to be found (the Wayback Machine hates me), but I have part of the website thanks to a Discord website description:


Click here for more tutorials! Here is a simple script, put it anywhere in a script section. This allows you to choose a password for the player to type. To use, put it in a scripted conditional...


It was a scripted conditional branch. So I went into the script editor, made a new script called password, and put in the following script:


def passCheck(password, helptext="What's the password?", minlength=0, maxlength=8, casesensitive=false)

code = pbEnterText(helptext, minlength, maxlength)

if code == password || (casesensitive == false && code.downcase == password.downcase)

return true

else

return false

end

end


After that, I went and made an event triggered by the action button using a Slowbro Sprite that looked like this:


@>Conditional Branch: Script: Password

@>Text: Hmm, work?

@>

: Else

@>Text: Not working...

@>

: Branch End

@>


I went in, playtested, and when I activated the event I got the following error:


Compiler:391:in `csvPosInt!'

Compiler:466:in `pbGetCsvRecord'

Compiler:462:in `each'

Compiler:462:in `pbGetCsvRecord'

Compiler:1536:in `pbCompileItems'

Compiler:1535:in `pbCompilerEachCommentedLine'

Compiler:251:in `each_line'

Compiler:251:in `pbCompilerEachCommentedLine'

Compiler:248:in `open'

Compiler:248:in `pbCompilerEachCommentedLine'

[Pokémon Essentials version 17.2]

Exception: Hangup

Message: The script is taking too long. The game will restart.

Compiler:2302:in `pbCompilePokemonForms'

Compiler:2300:in `each'

Compiler:2300:in `pbCompilePokemonForms'

Compiler:2294:in `each'

Compiler:2294:in `pbCompilePokemonForms'

Compiler:4398:in `pbCompileAllData'

Compiler:4515

[Pokémon Essentials version 17.2]

Exception: RuntimeError

Message: Script error within event 11 (coords 10,11), map 43 (Airplane2):

Exception: NameError

Message: (eval):1:in `pbExecuteScript'uninitialized constant Interpreter::Password

***Full script:

Password

Interpreter:243:in `pbExecuteScript'

Interpreter:794:in `eval'

Interpreter:243:in `pbExecuteScript'

Interpreter:794:in `command_111'

Interpreter:320:in `execute_command'

Interpreter:193:in `update'

Interpreter:106:in `loop'

Interpreter:198:in `update'

Scene_Map:163:in `update'

Scene_Map:161:in `loop'


Interpreter:276:in `pbExecuteScript'

Interpreter:794:in `command_111'

Interpreter:320:in `execute_command'

Interpreter:193:in `update'

Interpreter:106:in `loop'

Interpreter:198:in `update'

Scene_Map:163:in `update'

Scene_Map:161:in `loop'

Scene_Map:170:in `update'

Scene_Map:234:in `main'


So after a while of me being annoyed that it wasn't working, I decided to learn a bit of Ruby. I noticed a major problem with the def part of the script, and made it like so:


def passCheck(password,helptext,minlength,maxlength,casesensitive)

 code=pbEnterText(helptext,minlength,maxlength)

 if code==password || (casesensitive==false && code.downcase==password.downcase)

  return true

 else

  return false

 end

end


passCheck("password","What's the password?",0,8,false)


When I playtested, it came up with a screen that said, "What's the password?" and the normal text entry with 8 spots. I entered in "password" and it went through the intro. When I tried the event, I got the same error. So I read the internet and thought I found a guide on how to activate a global switch inside of a script. So I changed the script to be:


def passCheck(password,helptext,minlength,maxlength,casesensitive)

 code=pbEnterText(helptext,minlength,maxlength)

 if code==password || (casesensitive==false && code.downcase==password.downcase)

  $game_switches[65] = true

 else

  return false

 end

end


passCheck("password","What's the password?",0,8,false)


I playtested, got the same password screen at the start, but when I put in "password", I got the following error:


Script 'Password' line 4: NoMethodError occured.

undefined method `[]=' for nil:NilClass


It has to do with the switches thing, but I don't know exactly what the problem is.


TLDR: I'm having issues with a script I found in a tutorial in the old wiki, any ideas on how to make it so I don't get the errors I've been getting, and maybe how to make it so it only occurs during an event?

(edited by administrators)
0 1
  • Upvote
  • Reply
ShinyTogedemaru
0
• 9/30/2018

UPDATE:When I incorrectly put the password in, I don't get any error, and when I talk to the Slowbro, it says "Not working...", so I'm close, I hope.

UPDATE UPDATE: I'm stupid, that wasn't the case :P I changed the event so it worked with the global switch, and never changed it back. So anyway, still no luck, even with an incorrect password.

Write a reply...