Textbox in game

Textbox in game

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

Post Reply
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Textbox in game

Post by Von66341 »

Hey!

Does anyone know if it is possible to create a textbox function in the game?

Thanks!
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Textbox in game

Post by smoth »

Which game?
User avatar
SinbadEV
Posts: 6475
Joined: 02 May 2005, 03:56

Re: Textbox in game

Post by SinbadEV »

I believe he is referring to his own game.

Short answer "Probably, Lua can do pretty much anything."
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Textbox in game

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Textbox in game

Post 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
adamden02
Posts: 1
Joined: 02 May 2011, 08:42

Re: Textbox in game

Post by adamden02 »

What game do you say ?
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Textbox in game

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Textbox in game

Post 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
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Textbox in game

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Textbox in game

Post 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.
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Textbox in game

Post 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.
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Textbox in game

Post by Von66341 »

I just played zero k.

The line 'Say: ..' is not shifted.
Von66341
Posts: 111
Joined: 10 Feb 2011, 03:00

Re: Textbox in game

Post 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?
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

Re: Textbox in game

Post by CarRepairer »

I would just move the existing text input, see chilichat.
Post Reply

Return to “Game Development”