ID:154764
 
SO I was wanting to get the text someone inputted into a new window to use as their username. So when they click the username button, a window pops up and they can type it in and click submit, something like BE. This is all I pretty much got..

var/Username = winget(src, "TextInput.Text","Text")

But There's also an enter button, so when they click enter, the username they typed in the window, gets set as their username. I didn't know where to go from here so I can use the var to set there username :S
I don't get (no pun intended) why you need winget at all and not a simple input
In response to Kccmt
Kccmt wrote:
I don't get (no pun intended) why you need winget at all and not a simple input

I just like windows, it's a habit :S. And I thought winget would probably be easier
That's how you get the text from an input, assuming "TextInput" is the window and "Text" is the input control.

What is the problem? Are you asking how to make the button call the verb to use that line of code you provided?
In response to Kaiochao
Kaiochao wrote:
That's how you get the text from an input, assuming "TextInput" is the window and "Text" is the input control.

What is the problem? Are you asking how to make the button call the verb to use that line of code you provided?

Yeah, Since Username = winget etc etc, how would I use that, that's where I'm stuck, I want it so when I click Enter, it will set the Username. Right now I think all I have is the username var equalling winget(src, "TextInput.Text","text") but I'm triyng to figure out how I'd use the var.
In response to Chaorace
Chaorace wrote:
Kccmt wrote:
I don't get (no pun intended) why you need winget at all and not a simple input

I just like windows, it's a habit :S. And I thought winget would probably be easier

But input does open a window (a dialogue, but still a window)
In response to Kccmt
Kccmt wrote:
Chaorace wrote:
Kccmt wrote:
I don't get (no pun intended) why you need winget at all and not a simple input

I just like windows, it's a habit :S. And I thought winget would probably be easier

But input does open a window (a dialogue, but still a window)

Yeah, but I like having control over w hat my window looks like , I don't think INput lets you do that?
In response to Chaorace
Use the variable like you would any other variable. What exactly are you trying to do?

// This is how people used to do it.
name = input(src, "What is your name?", "Name")

// This is what you're doing.
var username = winget(src, "TextInput.Text", "text")
*posts on developer forum*
In response to Kaiochao
Kaiochao wrote:
Use the variable like you would any other variable. What exactly are you trying to do?

> // This is how people used to do it.
> name = input(src, "What is your name?", "Name")
>
> // This is what you're doing.
> var username = winget(src, "TextInput.Text", "text")
> *posts on developer forum*



SO something like this?

mob
Login()
winshow(src, "default",1)
winshow(src, "Login", 0)





var/Username = winget(src, "TextInput.Text","text") // src undefined var

turf
Username
Click()
winshow(src, "TextInput", 1)
mob
verb
Submit//invalid proc definiton
Click()
var/minUsername = 6
var/maxUsername = 15
if(length(Username)<minUsername || length(u)>maxUsername)
winset(usr, "TextInput.UserNameLabel", "text=\"UserName: [minUsername] to [maxUsername]")
if(length(Username)>=minU && length(u)<=maxU)
usr.Username=winget(src, "TextInput.Text","text")
winset(src,"UserNameLabel", "text=\ Nice Name!")
sleep(15)
winshow(usr,"TextInput", 0)
else if(length(Username)=0)
winset(usr,"UserNameLabel", "text=\No Username entered!")
I am not that great with programming, so i get 2 errors.

In response to Chaorace
Ignore him. Do it your way. It looks much more professional. You just gotta set up a verb. Like, on your window with the input, have a button that says something like "OK" used to enter the text the player input and make that his name. Then, do something like this:

mob/verb/nameSelect()
var/Username = winget(usr, "window.window_id", "text")
if(!Username) return // don't allow them to select a blank name


Then, just assign the command to your button in that windowfile to the verbname "nameSelect" or so.
In response to Yusuke13
Yusuke13 wrote:
Ignore him. Do it your way. It looks much more professional. You just gotta set up a verb. Like, on your window with the input, have a button that says something like "OK" used to enter the text the player input and make that his name. Then, do something like this:

>
> mob/verb/nameSelect()
> var/Username = winget(usr, "window.window_id", "text")
> if(!Username) return // don't allow them to select a blank name
>
>

Then, just assign the command to your button in that windowfile to the verbname "nameSelect" or so.

Thanks, looking at yours I changed mien up a tiny bit nothing too giant

mob/verb/NameSubmit()
var/Username = winget(src, "TextInput.Text","text")
var/minUsername = 6
var/maxUsername = 15
Click()
if(length(Username)<minUsername || length(Username)>maxUsername)
winset(usr, "TextInput.UserNameLabel", "text=\"UserName: [minUsername] to [maxUsername]")
if(length(Username)>=minUsername && length(Username)<=maxUsername)
usr.Username=winget(src, "TextInput.Text","text")//THe error was right here of the undefined var
winset(src,"UserNameLabel", "text=\ Nice Name!")
sleep(15)
winshow(usr,"TextInput", 0)
else if(!Username)
winset(usr,"UserNameLabel", "text=\ No Username entered!")
return


I got the error: usr.Username udefined var
In response to Chaorace
Chaorace wrote:
Yusuke13 wrote:
Ignore him. Do it your way. It looks much more professional. You just gotta set up a verb. Like, on your window with the input, have a button that says something like "OK" used to enter the text the player input and make that his name. Then, do something like this:

> >
> > mob/verb/nameSelect()
> > var/Username = winget(usr, "window.window_id", "text")
> > if(!Username) return // don't allow them to select a blank name
> >
> >

Then, just assign the command to your button in that windowfile to the verbname "nameSelect" or so.

Thanks, looking at yours I changed mien up a tiny bit nothing too giant

mob/verb/NameSubmit()
> var/Username = winget(src, "TextInput.Text","text")
> var/minUsername = 6
> var/maxUsername = 15
> Click()
> if(length(Username)<minUsername || length(Username)>maxUsername)
> winset(usr, "TextInput.UserNameLabel", "text=\"UserName: [minUsername] to [maxUsername]")
> if(length(Username)>=minUsername && length(Username)<=maxUsername)
> usr.Username=winget(src, "TextInput.Text","text")//THe error was right here of the undefined var
> winset(src,"UserNameLabel", "text=\ Nice Name!")
> sleep(15)
> winshow(usr,"TextInput", 0)
> else if(!Username)
> winset(usr,"UserNameLabel", "text=\ No Username entered!")
> return

I got the error: usr.Username udefined var

That's because it should be usr.name and not usr.Username (unless you defined a var called Username, but I don't see why you should since "name" is already there for this purpose)
In response to Kccmt
mob/verb/NameSubmit()
set hidden = 1
var/name = winget(src, "TextInput.Text","text")
var/minname = 6
var/maxname = 15
Click()
if(length(name)<minname || length(name)>maxname)
winset(usr, "TextInput.UserNameLabel", "text=\" Your name has to be [minname] to [maxname] Characters!")
sleep(20)
winset(usr, "TextInput.UserNameLabel", "text=\"")
else if(length(name)>=minname && length(name)<=maxname)
winset(usr,"UserNameLabel", "text=\" This will be your name for the journey! ")
usr.name=winget(src, "TextInput.Text","text")
sleep(20)
winshow(usr,"TextInput", 0)
else if(!name)
winset(usr, "UserNameLabel", "text=\" Nothing was entered for a Username!")
sleep(20)
winset(usr, "UserNameLabel", "text=\ ")
return



Okay, I got the first two parts working, I just can't get that last part working, the part if there aren't any characters entered, the message will say it in the label, but when there's nothing entered it says the length message :S

and I also got a runtime error with this code

 turf
UsernameShow
Click()
winshow(src, "TextInput",1)


I'm still sort of new with coding, so sorry if I'm posting simple minded errors :S
In response to Chaorace
Okay I got that part working now, thanks everyone. I just had to re-order how I had it. My new problem is making it so if the person picking a username picks one somebody already has, they cant choose it. I'm using a list for this but I need to know how to make it gave a variable to the contents in the list but I don't think I'm doing this right.

mob/verb/NameSubmit()
set hidden = 1
var/name = winget(src, "TextInput.Text","text")
var/minname = 6
var/maxname = 15
var/list/nameslist
for(var/mob/x in nameslist)
if(x.name==name)
winset(usr, "UserNameLabel","text=\" Name already taken. Choose a different one")
return
if(!name)
usr<<"debug message23"
winset(usr, "UserNameLabel", "text=\" Nothing was entered for a Username!")
sleep(20)
winset(usr, "UserNameLabel", "text=\ ")
return
if(length(name)>=minname && length(name)<=maxname)
winset(usr,"UserNameLabel", "text=\" This will be your name for the journey! ")
usr.name=winget(src, "TextInput.Text","text")
nameslist += usr
sleep(20)
winshow(usr,"TextInput", 0)
SaveF()
usr<<"debug message54"
return
if(length(name)> 1 || length(name)<minname || length(name)>maxname)
winset(usr, "TextInput.UserNameLabel", "text=\" Your name has to be [minname] to [maxname] Characters!")
sleep(20)
winset(usr, "TextInput.UserNameLabel", "text=\"")
usr<<"debug message"
return


mob/proc/SaveF()
var/firstletter=copytext(src.name,1,2)
var/savefile/F = new("players/[firstletter]/[src.name].sav")
F["username"]<<src.name
src.Write(F)


Or access the save file and check each save for the username, I tried looking for libraries on list, since I never used them, but I can't find any.