Page 1 of 1
Textbox in game
Posted: 28 Apr 2011, 11:10
by Von66341
Hey!
Does anyone know if it is possible to create a textbox function in the game?
Thanks!
Re: Textbox in game
Posted: 28 Apr 2011, 15:14
by smoth
Which game?
Re: Textbox in game
Posted: 28 Apr 2011, 15:18
by SinbadEV
I believe he is referring to his own game.
Short answer "Probably, Lua can do pretty much anything."
Re: Textbox in game
Posted: 28 Apr 2011, 15:33
by smoth
Ah well 4 choices, in order of my belief best to worst.
Chili, redui, iceui, raw lua. The ones prior to raw lua are ui frameworks designed to make such elements easier.
Re: Textbox in game
Posted: 28 Apr 2011, 20:12
by knorke
easiest is to use the chat, see Argh's post in that thread:
http://springrts.com/phpbb/viewtopic.php?f=23&t=24431
there are numerous threads on
"Custom GUI?" where you can read up on which framework is best and find some help to set them up
* It is a tradition that at least one superlong post of infolog errors must be posted.
*haha you did not really believe that did you?
http://answers.springlobby.info/questio ... -developed
Re: Textbox in game
Posted: 02 May 2011, 08:47
by adamden02
What game do you say ?
Re: Textbox in game
Posted: 03 May 2011, 10:49
by Von66341
Doing experimentation in my own game.
I tried the chat method.
I manage to shift the infromation in the chat console to a new moveable menu.
Does anyone know how I could shift the line: '' Say: .." as well?
Thanks.
Re: Textbox in game
Posted: 03 May 2011, 10:57
by knorke
Does anyone know how I could shift the line: '' Say: .." as well?
dont think it is possible.
if your plan is to move the say: line over some textfield graphic then thats a bad idea imo.
Not checking for text length for one thing.
Here is some thread about making your own text inputbox from another game:
http://love2d.org/forums/viewtopic.php?f=5&t=1820
Something similiar would work in spring too.
Basically
Code: Select all
widget:KeyPressed(key)
input = input .. key
end
Re: Textbox in game
Posted: 03 May 2011, 11:51
by Von66341
I did a small testing on this.
Basically if I key cltr the spring.echo will be display.
include("keysym.h.lua")
function widget:KeyPress(key,mods,isRepeat,label,unicode)
if key == KEYSYMS.LCTRL then
Spring.Echo(" Left Clrt")
end
end
Hence if am thinking of display in a specific box?
I should draw the box and use glText to write the message?
I would need an array to story the specific alphabelt as well?
What about things like backspace and enter?
Am using a game to study on decision making and learning.
Majority parts to game are from Spring 1944 and it also includes other free licence scripts and stuff from other games.
Re: Textbox in game
Posted: 03 May 2011, 13:20
by knorke
I should draw the box and use glText to write the message?
thats what i would do. chili probally has something more "finished"
I would need an array to story the specific alphabelt as well?
you need some way to convert the keycode numbers to letters. Array would work.
Not sure what spring/lua has to offer for that, might be an easier way.
What about things like backspace and enter?
see the l├Âve thread, it has some stuff on how to delete last letter on backspace etc.
Re: Textbox in game
Posted: 04 May 2011, 11:03
by Google_Frog
Von66341 wrote:Does anyone know how I could shift the line: '' Say: .." as well?
I am sure this can be done, Zero-K does it.
Re: Textbox in game
Posted: 05 May 2011, 03:34
by Von66341
I just played zero k.
The line 'Say: ..' is not shifted.
Re: Textbox in game
Posted: 05 May 2011, 06:44
by Von66341
I manage to get a testing text box to work.
Code as following:
function widget:KeyPress(key,mods,isRepeat,label,unicode)
if key == KEYSYMS.BACKSPACE then
input = string.sub(input,1,-2)
else if key == KEYSYMS.SPACE then
input = input .. " "
else if key then
input = input = input .. label
end
But when key keys like H, I and Enter the default shortcut key will run, is there a way to disable this shortcut key when the player is keying inside the textbox?
Is there a way to clear the screen?
For e.g. i got a gl.Rect(x1,y1,x2,y2)
then if the timer reaches a certain timing, I want to replace the previous drawn rectangle to gl.Rect(a1,b1,a2,b2). Will this be possible?
Re: Textbox in game
Posted: 09 May 2011, 06:17
by CarRepairer
I would just move the existing text input, see chilichat.