3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: InputText.3dr Limit the number of characters  (Read 157 times)

« on: May 29, 2014, 05:56:16 AM »
Hi.

I want in InputText.3dr have Limit the number of characters for example maximum 15 number of characters. can anyone help me?

Thanks
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #1 on: May 29, 2014, 08:26:44 AM »
I don't know why anyone no answer me When I ask a question  ???

But for my Picture all answer me.
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #2 on: May 29, 2014, 11:36:04 AM »
Don't worry, behdadsoft, just my post always comes a little bit late because i'm a newbie in the forum.

Here is the script. It limites the characters to 15.

Code: [Select]
string Text;
int len;
int max = 15; //maximum characters
void Main()
{
   if (iInitializing())
   {
      Text = "Type some text...";
   }
   int c = iTypedChar(true);

    len = iStringLen(Text); //return the length of the string

   if ((c > 0) and (len < max))
   {
      Text += " ";
      Text[iStringLen(Text)-1] = c;
   }
   if (c == -2)
   {
      //back-space was pressed
      iStringLeft(Text,Text,iStringLen(Text)-1);
   }
   if (c == -1)
   {
      //enter was pressed
      Text = "";
   }
   iObjectTextSet(OBJ_0,Text);
}

Also here is the transformed project of the InputText.3dr
If we don't give up we can achieve the unthinkable!
« Reply #3 on: May 30, 2014, 07:06:41 AM »
Thank you Very Much Power Supersport. :D
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0

possible way, if we found will make a way.
« Reply #4 on: May 30, 2014, 09:28:10 AM »
You're welcome. Always there is something that we don't know. But for that is the forum - to ask questions and to receive them answered.
If we don't give up we can achieve the unthinkable!
« Reply #5 on: May 30, 2014, 12:16:53 PM »
I'm glad somebody else answered this question :P

I have a whole text input routine scripted that was based on jestermons original text input script.

I updated it and have added key repeat and string length control, basically a mini text processor.

One problem i haven't solved yet, not sure if I'll even bother to keep trying is that 3drad doesn't have any easy process to control text and prevent it from printing off screen.

You mite call that a feature that allows for some fancy text printing and text animation, but 3drad is missing that one option to limit text print to a given screen "input box" or even limit text to only the visible screen area.
( by adding a carriage return when the edge is reached, or disable input )

I had thought one time of using a math process to basically figure out how long a text string is by adding the actual screen width of each character times the number of characters in a string.

That wont always work easily if your not using a fixed width font, in that case it gets a little more involved to keep track of each letter and their widths then adding them up.

As you can see.. it gets really involved trying to control text to a input box on screen.

I even considered creating my own text print routine with my own sprite based fonts.

I figured it will work actually and allow "input box" type control, and colored text ( even every letter in a string having it's own color, and even changeable on the fly ).

I gave up on the custom text idea solely cause 3drad is abandon ware now and doesn't warrant the time involved to develop this.
« Reply #6 on: May 30, 2014, 02:05:02 PM »
and the curtain again raises on the theatre of the absurd...

--Mike
« Reply #7 on: June 03, 2014, 09:32:08 AM »
  ::) ;D ;D ;D
There is a most powerful driving force than steam, electricity and atomic energy: the force of will

---Albert Einstein---
Pages: [1]