Solarus-Games English Forum

Community => Your projects => Topic started by: Zefk on October 07, 2016, 04:16:13 AM

Title: Char input sneak peek
Post by: Zefk on October 07, 2016, 04:16:13 AM
My char input goes up to 15 places. I fixed the error with "3" in the gif. I forgot to remove a comment in the script due to test reasons. I will add capitals and fix the coordinate errors or it might be a space in the char image.

(https://media.giphy.com/media/3oz8xALQokXp5XpE5y/giphy.gif)
Title: Re: Char input sneak peek
Post by: Zefk on October 08, 2016, 08:17:37 AM
Added:
-Switch from shift to lower case
-Able to mix lowercase and uppercase characters
-The ability to delete or backspace

The lag slows the gif a little. Not caused by the script. It is super fast.
(https://media.giphy.com/media/l2Sqb1TcjHt94vGTu/giphy.gif)

Bugs:
-Space errors that need minor adjusting

Enhancements in progress:
-Passing the char to a name variable($v) for Christopho's text box. That way the char input can be used for names.
-Name tag. The char input passed on to a name plate that will be moved above the text box.
-Space input (space bar)

Besides those enhancements it can be used for word puzzles. For example, beating a boss or enemy can reward the player with an input space to prevent guessing.
Title: Re: Char input sneak peek
Post by: froggy77 on October 08, 2016, 07:44:42 PM
Interesting script for example to name the hero at the beginning of the game.
It seems in your .gif that it is possible to go from left to right. But, I don't understand why the cursor goes from "A" to "Enter" and not to "Cancel". Bug or lag or missing frame in the .gif?
Is it also possible to loop vertically (e.g. from "v" to "4" or from "4" to "v")?
Title: Re: Char input sneak peek
Post by: Zefk on October 08, 2016, 08:48:54 PM
QuoteBut, I don't understand why the cursor goes from "A" to "Enter" and not to "Cancel".

Enter is browse 24 and "a" is browse 25. Basically, it goes from around browse 1 - 48 for normal left and right browsing. I have it skip by 12 for up and down browsing. Number "1" and exclamation "!" mark (for shift or capital) do what you want, but it was because I was too lazy to scroll down and left to get to backspace.

QuoteIs it also possible to loop vertically (e.g. from "v" to "4" or from "4" to "v")?
It does indeed do that. I have it add and minus 48 for browsing looping to the other side with up and down.

(https://media.giphy.com/media/3o6ZtjViPYtbcjrH0Y/giphy.gif)


Title: Re: Char input sneak peek
Post by: Zefk on October 09, 2016, 12:03:16 AM
I added similar calculation controllers as I did for "browse 1" for left and right looping. I think this is what you wanted froggy77?

(https://media.giphy.com/media/26gJAhApqMNBw5WQ8/giphy.gif)
Title: Re: Char input sneak peek
Post by: froggy77 on October 09, 2016, 12:50:10 PM
This is the result I wanted expected. This allows a better and faster navigation.
Bravo!  8)
Title: Re: Char input sneak peek
Post by: Zefk on October 09, 2016, 11:35:22 PM
Glad you like it.

Besides that. I decided that naming 15 characters would be enough. I think the programmer can set the names manually with code for beyond 15 characters. Who really wants to name more that 4 characters anyway?

-Hero
-Rival
-Best friend
-Pet

Unless in the case of a monster game like Pokemon, but I never named them when playing those games.
Title: Re: Char input sneak peek
Post by: Zefk on October 10, 2016, 02:08:23 AM
I have completed some tests with passing char on from text box input and removing them. The "wp" is a random test. The character being named is activated with true or false. In this case both are true, so both characters are being named at the same time and that is why I added the random "wp" instead of "12" for character_2.

Code ( lua) Select

text_box.naming_character[1] = true
text_box.naming_character[2] = true


(https://media.giphy.com/media/l0HlHdUOLYAgUxNrW/giphy.gif)

Bug fixed:
-Fixed green block "browse 1" from showing on character movement. Set to browse 0 at start of script and browse 1 on activation of text box.
Title: Re: Char input sneak peek
Post by: Zefk on October 14, 2016, 12:30:30 PM
I did massive improvements for the script using arrays. It is quite easy to exceed 15 characters with number changes.

Added:
-Char input for capital and lowercase
-Clear all char images
-Clear concat string
-Removed limits with arrays (shortened the script by more than 75%)
-The ability name as many characters as one wants at one time. Name 150 monsters if you want. Otherwise, small pieces of code will have to be added for naming at different times or something along those lines.
---Changing the below will change the limits of the script.
-local char_limit = 15
-local char_amount = 16
-local char_image_num = 15
-local character_limit = 15
-local max_char = 15

Bugs:
-Space image errors that need minor adjusting, but has absolutely nothing to do with the script.
-Audio is lowered when skipping. Most likely due to rapid playing. Not 100% sure, but it kinda is a nice effect.

Bugs fixed:
-Backspace caused string deleting in reverse.
-skipping characters and marking them nil due to missing "break"

Enhancements in progress:
-Name tag. The char input passed on to a name plate that will be moved above the text box. (Similar to the bank script wallet number display)
-Picking of manually coded names. For example, Pokemon red, blue, yellow, has a list of names to choose from for names.
-Space input (space bar)
-Cancel (clear everything and repeat on some decision.)

(https://media.giphy.com/media/l0HlNddJX48cImeGc/source.gif)
Title: Re: Char input sneak peek
Post by: Zefk on October 17, 2016, 04:11:50 AM
I added a few things today. I added the space input and manually coded names.

(https://media.giphy.com/media/l4pMgx30csF1u19N6/source.gif)

Added:
-Space input
-Picking of manually coded names. For example, Pokemon red, blue, yellow, has a list of names to choose from for names.

Enhancements in progress:
-Name tag. The char input passed on to a name plate that will be moved above the text box. (Similar to the bank script wallet number display)
-Cancel (clear everything and repeat on some decision.)

Bugs:
-Space image errors that need minor adjusting, but has absolutely nothing to do with the script.
-Audio is lowered when skipping. Most likely due to rapid playing. Not 100% sure, but it kinda is a nice effect.

Bugs fixed:
-Green box still shows on zefk after enter. You will notice the error in the gif.
Title: Re: Char input sneak peek
Post by: MetalZelda on October 17, 2016, 01:25:39 PM
Clever, nice inclusion of this system into the dialog box system

This could be nice for some puzzles
Title: Re: Char input sneak peek
Post by: Zefk on October 17, 2016, 03:11:45 PM
The enhancement I am adding will turn a string into image text, but the images can really be anything. I might make it into a dialog system later, but my plans are to go do the easy scripts on my list and shorten existing scripts with arrays.
Title: Re: Char input sneak peek
Post by: Zefk on October 18, 2016, 10:07:58 AM
I finished the string to image text. I added a feature where there is sorta a wrap text, but it will be limited to three lines because I do not see three characters speaking at the same time unless they all say the same sentence. You know those moments.
(https://media.giphy.com/media/3oriObxveamisdjGh2/source.gif)
Title: Re: Char input sneak peek
Post by: MetalZelda on October 18, 2016, 08:43:45 PM
What's weird in your last post is that the box is drawn bellow entities, otherwize there is nothing more to say except it's a nice feature

One thing the moderator should do is, add a new subforum where there would be only scripts for Solarus
Title: Re: Char input sneak peek
Post by: Diarandor on October 18, 2016, 08:56:50 PM
@Zefk:
It is good to see that you have progressed a lot with this script. Your work looks promising and may be useful to other people.

And I agree: you are grand! ;D
Title: Re: Char input sneak peek
Post by: Zefk on October 18, 2016, 10:33:52 PM
Quote from: MetalZelda on October 18, 2016, 08:43:45 PM
What's weird in your last post is that the box is drawn bellow entities, otherwize there is nothing more to say except it's a nice feature

@MetalZelda
I grabbed the black tile and made the black box for the gif. The purple text would be hard to see and I did not want to make a black image.

QuoteIt is good to see that you have progressed a lot with this script. Your work looks promising and may be useful to other people.

@Diarandor
It was very tricky for the first 10 minutes with this script, but due to that I can add more features.  Without "string.reverse" the text would be backwards and I can make the text look like a slash or a diagonal line. These features might be useful for some puzzles or looped animation and were done by accident.

EX:
zefk
kfez

z
  e
    f
     k
       i
        s
          g
            r
             a
               n
                 d

This could be made to pass values too, but that is a bit tricky to make. I would probably use this char  ``````. That would be for 6 places. 999,999. I would probably do that if I make this into a dialog box.
Title: Re: Char input sneak peek
Post by: oclero on October 19, 2016, 12:53:50 AM
Quote from: MetalZelda on October 18, 2016, 08:43:45 PM
One thing the moderator should do is, add a new subforum where there would be only scripts for Solarus

Actually it already exists: isn't it the Development subforum ?  :)
Title: Re: Char input sneak peek
Post by: Zefk on October 19, 2016, 12:55:40 AM
I added the diagonal line, reverse text feature, and a third line. The gif proves that special characters can be used too. !#@

I mentioned this before, but any images can be used.

EX:
Apple.png can appear for the 'a' and/or orange.png can appear for 'o'. Names will have to be changes in the script or a.png can be an apple image.

(https://media.giphy.com/media/l0MYQiC1XiDTSbtDO/source.gif)
Title: Re: Char input sneak peek
Post by: Zefk on October 19, 2016, 02:33:40 AM
Quote from: Neovyse on October 19, 2016, 12:53:50 AM
Quote from: MetalZelda on October 18, 2016, 08:43:45 PM
One thing the moderator should do is, add a new subforum where there would be only scripts for Solarus

Actually it already exists: isn't it the Development subforum ?  :)

@Neovyse
I believe the description of the Development subforum is examples of scripts, help questions, tips, etc. It is not a place for "only" working scripts submissions for Solarus v1.x.x, but I honestly do not mind either way. I post my scripts here (http://forum.solarus-games.org/index.php?topic=624.msg3159#msg3159) when finished.

As this is a scripting development 'project.' I am just getting feedback here until the script is good enough to release. I will actually release it in one script and 3 separate scripts because maybe they only want to use one part of the naming process (Nameplate, input text, and picking names.) or so they can make it compatible with their project.

All that is left for me to do is add cancel, add comments/clean up, and package this project.
Title: Re: Char input sneak peek
Post by: MetalZelda on October 19, 2016, 12:35:10 PM
Quote from: Neovyse on October 19, 2016, 12:53:50 AM
Quote from: MetalZelda on October 18, 2016, 08:43:45 PM
One thing the moderator should do is, add a new subforum where there would be only scripts for Solarus

Actually it already exists: isn't it the Development subforum ?  :)

Yes but the development subforum is mostly about the API scripts, there is user-made scripts, but they are a bit dispatched over the whole subforum, between some help threads.
A "script" subforum should be better, as it would contain scripts for solarus, and only scripts.
Plus, it could be useful to add in the "help" section of the Quest Editor a "Script" box which will redirect to this subforum

I don't know what do you think

Title: Re: Char input sneak peek
Post by: oclero on October 20, 2016, 02:13:54 PM
I agree we should maybe create sort of a "library" of user scripts, now that Solarus have more users!
Title: Re: Char input sneak peek
Post by: Christopho on October 20, 2016, 02:24:51 PM
Ok I just created a new forum section "Your scripts".
Title: Re: Char input sneak peek
Post by: Zefk on October 20, 2016, 09:21:07 PM
I will post my previous scripts there, once I shorten them with arrays and add loading with require.
Title: Re: Char input sneak peek
Post by: llamazing on October 21, 2016, 08:15:00 AM
I haven't seen your script, but you should avoid using string.reverse() for text displayed on-screen because it is not compatible with multi-byte utf-8 strings (used in non-english text). If you really need to reverse a string, I guess you could write a custom reverse function that is utf-8 friendly.
Title: Re: Char input sneak peek
Post by: Zefk on October 21, 2016, 10:45:59 AM
I think I can do it without string.reverse().

Code ( lua) Select
local test = "test"
local test_split = {}

for char in string.gmatch(test, "%w") do
  table.insert(test_split, char)
end


It does the opposite of my previous code. (Which is normal order.) I use reverse to make the text not reversed because they are reverse to begin with. Not sure if it makes a difference, but any alphabetical character can refer to any png image font character.
Title: Re: Char input sneak peek
Post by: Zefk on October 24, 2016, 03:02:10 AM
I decided to extend this script a little further. I will be adding a sol.text_surface.create option. That is for people that want to use font packages. It will actually be very little change in the scripts.