SetWindowSize( 1280,720, 0 )
SetWindowAllowResize( 1 )
// set display properties
SetVirtualResolution( 1280,720)
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 )
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 )
GLOBAL Players as String []
GLOBAL MaxPlayers = 8
GLOBAL NumPlayers as Integer
Repeat
Print("Number of Players? (1-"+STR(MaxPlayers)+")")
NumPlayers = VAL( CHR (GetRawLastKey()) )
Sync()
Until NumPlayers > 0 and NumPlayers <= MaxPlayers
AddPlayers()
do
If GetRawKeyState(27) then End
For x = 0 to Players.Length
Print("Player "+STR(x+1) + ": " + Players[x])
Next x
Sync()
loop
Function AddPlayers()
TempTextID = CreateText("")
SetTextSize(TempTextID,36)
SetTextPosition(TempTextID, 100,50)
For x = 1 to NumPlayers
SetTextString(TempTextID, "Enter Player " + STR(x) + " Name:")
ThisPlayerName$ = Input_Player_Name()
Players.Insert(ThisPlayerName$)
Next x
DeleteText(TempTextID)
EndFunction
Function Input_Player_Name()
StartTextInput ( )
Repeat
Name$ = GetTextInput ()
Sync()
Until GetTextInputCompleted() = 1
EndFunction Name$
GLOBAL NumPlayers as Integer
Function AddPlayers()
TempTextID = CreateText("")
SetTextSize(TempTextID,36)
SetTextPosition(TempTextID, 100,50)
For x = 1 to NumPlayers
SetTextString(TempTextID, "Enter Player " + STR(x) + " Name:")
ThisPlayerName$ = Input_Player_Name()
Players.Insert(ThisPlayerName$)
Next x
DeleteText(TempTextID)
EndFunction
You should let createText() generate the ID of each and assign its returned integer value to a variable. Much easier to manage and no worries of using duplicate IDs.
o you see how this might work?
here, you have much more control and functionality including the ability to set its background image.
CreateEditBox( 1 )
SetEditBoxBorderSize( 1, 0.5 )
SetEditBoxBorderColor( 1, 0, 0, 0, 255 )
SetEditBoxMaxChars( 1,8 )
SetEditBoxPosition( 1, 30, 25 )
SetEditBoxSize( 1, 15.5, 4)
SetEditBoxTextSize( 1, 10 )
SetEditBoxCursorWidth( 1, 0.3 )
SetEditBoxCursorPosition( 1,5)
SetEditBoxScissor( 1, 0, 0, 0, 0 )
FixEditBoxToScreen ( 1, 1 )
SetEditBoxPosition( 1, 17.5, 34.5 )
Name$= GetEditBoxText( 1 )
SetEditBoxText( 1, Name$ )
didn't know if you knew so I thought I show you.
I see the text typed out on screen, but when I press enter nothing happens
I get an error saying an image can't be loaded because the ID is already in use in an #include file that hasn't been accessed yet
// Project: name
// Created: 2022-02-27
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "name" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
CreateEditBox( 1 )
SetEditBoxBorderSize( 1, 5.0 )
SetEditBoxBorderColor( 1, 0, 0, 0, 255 )
SetEditBoxMaxChars( 1,8 )
SetEditBoxSize( 1, 300, 50)
SetEditBoxTextSize( 1, 80 )
SetEditBoxCursorWidth( 1, 5 )
SetEditBoxCursorPosition( 1,1)
SetEditBoxScissor( 1, 0, 0, 0, 0 )
FixEditBoxToScreen ( 1, 1 )
SetEditBoxPosition( 1, 350 ,350 )
SetEditBoxFocus(1,1)
Name_text=CreateText ( "" )
SetTextPosition ( Name_text,5.5, 30)
SetTextSize ( Name_text, 5 )
FixTextToScreen ( Name_text, 1 )
SetTextColor(Name_text,0,0,0,255)
SetTextVisible(Name_text,0)
Name$= GetEditBoxText( 1 )
SetEditBoxText( 1, Name$ )
do
Wrote_Name=GetEditBoxCursorPosition( 1 )
Name$= GetEditBoxText( 1 )
print( Name$)
Sync()
loop
I wrote this small example for you
Player_1$= GetEditBoxText( 1 )
Player_2$= GetEditBoxText( 2 )
Player_3$= GetEditBoxText( 3 )
Player_4$= GetEditBoxText( 4 )
Player_5$= GetEditBoxText( 5 )
Player_6$= GetEditBoxText( 6 )
Player_7$= GetEditBoxText( 7 )
Player_8$= GetEditBoxText( 8 )
SetEditBoxText( 1, Player_1$ )
SetEditBoxText( 2, Player_2$ )
SetEditBoxText( 3, Player_3$ )
So on and so forth
// Project: name
// Created: 2022-02-27
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "name" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 1024, 768 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
P=50
for x=1 to 8
CreateEditBox( x )
SetEditBoxBorderSize( x, 5.0 )
SetEditBoxBorderColor( x, 0, 0, 0, 255 )
SetEditBoxMaxChars( x,8 )
SetEditBoxSize( x, 300, 50)
SetEditBoxTextSize( x, 80 )
SetEditBoxCursorWidth( x, 5 )
SetEditBoxCursorPosition( x,1)
SetEditBoxScissor( x, 0, 0, 0, 0 )
FixEditBoxToScreen ( x, 1 )
SetEditBoxPosition( x, 350 ,P )
inc P,90
next x
SetEditBoxFocus(1,1)
SetEditBoxText( 1, Name_1$ )
SetEditBoxText( 2, Name_2$ )
SetEditBoxText( 3, Name_3$ )
SetEditBoxText( 4, Name_4$ )
SetEditBoxText( 5, Name_5$ )
SetEditBoxText( 6, Name_6$ )
SetEditBoxText( 7, Name_7$ )
SetEditBoxText( 8, Name_8$ )
P=5
For x=1 to 8
createtext(x,"Player="+str(x))
SetTextSize(x,50)
SetTextPosition(x,410,P)
inc P,90
next x
do
Name_1$ = GetEditBoxText( 1 )
Name_2$ = GetEditBoxText( 2 )
Name_3$ = GetEditBoxText( 3 )
Name_4$ = GetEditBoxText( 4 )
Name_5$ = GetEditBoxText( 5 )
Name_6$ = GetEditBoxText( 6 )
Name_7$ = GetEditBoxText( 7 )
Name_8$ = GetEditBoxText( 8 )
print( "Player 1=" + Name_1$)
print( "Player 2=" + Name_2$)
print( "Player 3=" + Name_3$)
print( "Player 4=" + Name_4$)
print( "Player 5=" + Name_5$)
print( "Player 6=" + Name_6$)
print( "Player 7=" + Name_7$)
print( "Player 8=" + Name_8$)
Sync()
loop
o if you click on a edit box that edit box has focus, then the player adds the name then the next edit box is clicked on, you will have to save each name differently due to each edit box.
In this case I need to ask are you working on a server for players or home controller players?