Jump to content
  • 0

Why is input not showing up in this context?


Leeg

Question


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  120
  • Reputation:   44
  • Joined:  11/13/11
  • Last Seen:  

 

I've written these few lines and I've found out that "input" is not working. But I can't understand why. The script just stops right before the input should be showing up and nothing happens. No errors. No warnings. Nothing. Where is the problem? Thank you very much.

	.@loop1 = 1;
	while(.@loop1){
	
		mes "Choose an option";
		next;
			switch(select("One:Two:Three")) {
			case 1:
			mes "Write a number between 0 and 6.";
			while(1){
				input .@TdayofWeek;
				if ((.@TdayofWeek >= 0) && (.@TdayofWeek <= 6))
					break;
			}

 

Edited by Leeg
Link to comment
Share on other sites

9 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  120
  • Reputation:   44
  • Joined:  11/13/11
  • Last Seen:  


Found out the bug!

The input works with this npc declaration: -    script    wisp    -1,{

 

The input doesn't work with this npc declaration: prontera,143,185,1    script    wisp    -1,{

 

Is that normal?

Edited by Leeg
Link to comment
Share on other sites

  • 1

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

4 hours ago, Leeg said:

Found out the bug!

The input works with this npc declaration: -    script    wisp    -1,{

The input doesn't work with this npc declaration: prontera,143,185,1    script    wisp    -1,{

Is that normal?

I was able to reproduce this... Although I'm not sure if I'd call it a bug. It's got something to do with the way npcs are loaded.
If you're within the range of the npc ~21 squares or something like that it will act fine.

A few other side notes:

			while(1){
				input .@TdayofWeek;		//Script stops working right here. Input doesn't show up.
				if ((.@TdayofWeek >= 0) && (.@TdayofWeek <= 6))
					break;
            }

Can be replaced with...

while( input( .@TdayofWeek, 0, 6 ) ){}

 

Also I don't recommend using -1 as the sprite on an npc that is approachable by players. It's caused problems for me in the past with specific clients.
I instead recommend using 104.

Sprite 104 = Invisible, Unclickable.
Sprite 111 = Invisible, Clickable.
Sprite 844 = Shadow, Clickable.

  • Upvote 2
Link to comment
Share on other sites

  • 0

  • Group:  Forum Manager
  • Topic Count:  282
  • Topics Per Day:  0.06
  • Content Count:  3126
  • Reputation:   1617
  • Joined:  03/26/12
  • Last Seen:  

"In this context" no one can really help you, you're using a while loop with a predetermined value that doesn't change. Remove the while clause before input and validate the data properly. 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  120
  • Reputation:   44
  • Joined:  11/13/11
  • Last Seen:  

The while loop value is changed properly when needed. If that was the issue, the script would be bugged way before the input. What do you mean by validate the data properly? And how would that have any effect on the input box showing up?

If more context is needed, this is the whole thing:

OnWhisperGlobal:
if(getgmlevel() > 50){
  
	.@loop1 = 1;
	while(.@loop1){
	
		mes "Choose an option";
		next;
			switch(select("Option1:Option2:Option3")) {
			case 1:
			mes "Write a number between 0 and 6.";
			while(1){
				input .@TdayofWeek;		//Script stops working right here. Input doesn't show up.
				if ((.@TdayofWeek >= 0) && (.@TdayofWeek <= 6))
					break;
			}
			setarray $dayofWeek[getarraysize($dayofWeek)], .@TdayofWeek;
			break;
			
			case 2:
			//Nothing yet
			break;
			
			case 3:
			.@loop1 = 0;
			break;
			
		}
	}
	close;

}

 

Edited by Leeg
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  303
  • Reputation:   117
  • Joined:  12/10/16
  • Last Seen:  

I tried your script this way:
 

-	script	wisp	-1,{
OnWhisperGlobal:
	if(getgmlevel() > 50){
  
		.@loop1 = 1;
		while(.@loop1){
	
			mes "Choose an option";
			next;
				switch(select("Option1:Option2:Option3")) {
				case 1:
				mes "Write a number between 0 and 6.";
				while(1){
					input .@TdayofWeek;		//Script stops working right here. Input doesn't show up.
					if ((.@TdayofWeek >= 0) && (.@TdayofWeek <= 6))
						break;
				}
				setarray .@dayofWeek[getarraysize(.@dayofWeek)], .@TdayofWeek;
				break;
			
				case 2:
				//Nothing yet
				break;
			
				case 3:
				.@loop1 = 0;
				break;
			
			}
		}
		close;

	}
}

and couldn't reproduce. It worked right.
This test was made with the latest git commit. What version are you using?
A weird issue indeed.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  230
  • Reputation:   131
  • Joined:  11/21/11
  • Last Seen:  

You're right, it doesn't work if you set the NPC in a map, but only with no sprite (-1). It works fine with any sprite, both clicking and whispering.

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  120
  • Reputation:   44
  • Joined:  11/13/11
  • Last Seen:  

If it can't be considered a bug, then I think the problem is solved.

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  30
  • Topics Per Day:  0.01
  • Content Count:  230
  • Reputation:   131
  • Joined:  11/21/11
  • Last Seen:  

45 minutes ago, Leeg said:

If it can't be considered a bug, then I think the problem is solved.

I'm not sure if this is the intended behaviour though

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

6 hours ago, Daegaladh said:

I'm not sure if this is the intended behaviour though

I would agree although it is completely avoidable.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...