input string for hero name

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Gigglyardo
Slime
Posts: 9
Joined: Sun Aug 16, 2015 1:20 am

input string for hero name

Post by Gigglyardo »

look here pal
so i wanna make it so that the player can type their own name
i've already accomplished this with

Code: Select all

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
User avatar
kylekrack
Liquid Metal Slime
Posts: 1240
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

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: Select all

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
My pronouns are they/them
Ps. I love my wife
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

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.
User avatar
Gigglyardo
Slime
Posts: 9
Joined: Sun Aug 16, 2015 1:20 am

Post by Gigglyardo »

oh my goodness it's a miracle thanks
Post Reply