Post new topic    
Slime
Send private message
input string for hero name 
 PostTue Mar 20, 2018 5:56 am
Send private message Reply with quote
look here pal
so i wanna make it so that the player can type their own name
i've already accomplished this with
Code:

input string (1, 7, true, true)
set hero name (1, me)


the problem is, currently you can press 'enter' and the name will be blank.
i want to force the player to type a name before they proceed, ya dig?

please help me this is important probably the most important thing in my young boy life
Liquid Metal Slime
Send private message
 
 PostTue Mar 20, 2018 7:40 am
Send private message Reply with quote
You can check for the length of the input string with "string length(ID)". I guess you'd probably want to do it in a while loop to make sure it doesn't let you move on until a valid input has been entered.
Code:
script, new name, begin
    while(true) do(
        input string(1, 7, true, true)
        if(string length(1) > 0) then(
            set hero name(1, me)
            break    # breaks out of the while loop and moves on
        )
    )
    # script will continue here after break
end

I can't write in cursive.
Metal King Slime
Send private message
 
 PostTue Mar 20, 2018 8:40 am
Send private message Reply with quote
kylekrack's script will work. But there is actually a builtin command to show a prompt to edit a hero's name. It doesn't allow you to enter a blank name, but it does let you cancel by pressing ESC, in which case the name isn't changed.

Actually there are two commands, "rename hero" takes the hero ID, eg "rename hero(hero:bob)" or "rename hero(leader)"; and "rename hero by slot" takes the party slot number.

"rename hero" shows a proper box and prompt whereas "input string" shows nothing on the screen except the string, that's why you might prefer "rename hero"

If you don't want to let the player cancel, you can use a while loop very similar to the one kylekrack posted.
Slime
Send private message
 
 PostWed Mar 21, 2018 12:18 am
Send private message Reply with quote
oh my goodness it's a miracle thanks
Display posts from previous: