Script Coding error? Help?

Hi,

So I'm newish to RPG Maker VX Ace and the community, I just completed an online Ruby course, I feel fairly confident but I know I still have a lot to learn.

First of all I wrote this script as the start of a computer hacking script and while I'm not getting any errors it also doesn't run in order. 

It starts by calling the name input window (it should call a message window) twice, then it displays one message containing "username please, password please, yay" on different lines. needless to say I'm lost.

def new #--- Working Perfect ---# users = {Cameron: "aklefn", Llyod: "janed"} #Hash for Usename/password user = ["Cameron","Llyod"] #array to sample name (randomization) name = user.sample{|n| n.to_str} #sample from array, set return to string pass = users.fetch(name.to_sym) #fetch value of name(as symbol) from hash #---Need Help With---# $game_message.add("Username Please") #send message (Duh) SceneManager.call(Scene_Name) ##Name input screen for actor 99 SceneManager.scene.prepare(99, 12) ## if name = $game_actors[99].name #Conditional to check username $game_message.add("Password Please") #if true ask for password SceneManager.call(Scene_Name) ##Name Input screen for actor 100 SceneManager.scene.prepare(100, 12) ## if pass = $game_actors[100].name #Conditional to check password $game_message.add("Yay") # Message if password = true else $game_message.add("sorry") #message if password = false end else $game_message.add("Sorry") #Message if username = false end endAlso problem number two is I have to put my scripts directly into the Game_Interpreter Script 

 

I have this:

 

class Test < Game_Interpreter def initialize end def new end endend

 

set up under materials and when i try  to call Initialize it returns an attempt to call a private method, when i cal New it just doesn't do anything( Yes when i was calling there was Valid code in the method) and returns no errors. the code i am using to call with is:

 

Test.new

 

 

But if i put the code directly into the Game_Interpreter Script and call Game_Interpreter.new or mixin Game_interpreter to my script and call self.new it works just fine.

 

Also I apologize for my formatting I've never been the greatest in that department.

any help would be appreciated 
Well, you're telling it to put something onto the message queue, but you're not telling it to wait for it to be displayed.


Look at some of the other scenes (in particular, Scene_Map), to see what they do with regard to showing messages and waiting for them to be displayed.


Also, putting your scripts in code tags will make them much easier to read.
thanks for the info ill go look into that, as far as the code tags not exactly sure how to do that 
[*code]


code goes here


[*/code]


except without the * at the start.
Thanks is that better
1) Why are you inheriting from Game_Interpreter?

2) I'm guessing it's putting up the two input boxes as a result of your two consecutive fetch calls. I don't think RGSS3 - which is what you're really coding in, think of it as a subset of Ruby, does threads. It can do fibers, but why use either here?

3) It's putting "username please" "password please" "yay" all on one line because you're not telling it to do anything in between...

4) You really do need to work on your formatting if you want other people to be able to read your code.

Who knows? Someday you may want to write something in Python and you'll be really hosed...
@Mouser

1)As for my formatting again I apologize, I've actually been programming and scripting for almost 15 years, but only for myself, this is actually the first time I have EVER posted any piece of code, in fact I think this the first time I've ever posted on a forum. After completing my Ruby course I started a Python course so I do know what your talking about.

2)All the Fetch call is doing is pulling the value of the key name.to_sym from the hash users, that's how I'm getting the password. Actually that part of the script works fine. I can take that part and just print the two values "name and pass". Something past that is where the problem is.

3)It's putting all the phrases on different lines in the same message and not displaying ALL the messages. The way i read it it says message(Username) request(username) if (Username) = (Hash Name) move on get password same way. Correct me if I'm wrong PLEASE.

4)Inheriting Game_Interpreter was part of a test and i forgot to remove it before posting, Sorry.

5) Made a Few changes to the formatting hopefully it helps to read.

Original thread: https://forums.rpgmakerweb.com/threads/script-coding-error-help.24989/