Textbox Help
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- squidborne_destiny
- Prole
- Posts: 8
- Joined: Wed May 28, 2014 8:32 pm
Textbox Help
Hey guys, I am new to love and I was looking for a way to create textboxes similar to those in Legend of Zelda; where I can press "z" and move through pages. Right now I am spawning Npcs and giving the a string parameter, but it does not work for multiple pages. Any help is appreciated, thanks.
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
- squidborne_destiny
- Prole
- Posts: 8
- Joined: Wed May 28, 2014 8:32 pm
Re: Textbox Help
Thanks!Roland_Yonaba wrote:Take a look at Litearc's Navi.
And welcome to LÖVE.
- squidborne_destiny
- Prole
- Posts: 8
- Joined: Wed May 28, 2014 8:32 pm
Re: Textbox Help
Hey I was wondering if there was a way to take on string of text and save it as multiple variables in a table.
Re: Textbox Help
Sure.
Code: Select all
String = 'This is my string'
Part1 = String:sub( 1, 4 ) -- "This"
Part2 = String:sub( 6, 7 ) -- "is"
-- etc.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Textbox Help
What you want is a Split function:
The delimiter is the character you want to split it at. In your case probably a space. The string part would be the variable you are storing the text in.
But if I were you doing a message box and you want it to type itself in use the string.sub() function instead and local value to the message box that ticks up every frame (Use dt) and grab the text from character 1 to math.floor(message_box_caret_position). This will print it in one character at a time like you see in all RPGs.
Code: Select all
function string:split(delimiter)
local result = { }
local from = 1
local delim_from, delim_to = string.find( self, delimiter, from )
while delim_from do
table.insert( result, string.sub( self, from , delim_from-1 ) )
from = delim_to + 1
delim_from, delim_to = string.find( self, delimiter, from )
end
table.insert( result, string.sub( self, from ) )
return result
end
But if I were you doing a message box and you want it to type itself in use the string.sub() function instead and local value to the message box that ticks up every frame (Use dt) and grab the text from character 1 to math.floor(message_box_caret_position). This will print it in one character at a time like you see in all RPGs.
- Roland_Yonaba
- Inner party member
- Posts: 1563
- Joined: Tue Jun 21, 2011 6:08 pm
- Location: Ouagadougou (Burkina Faso)
- Contact:
Re: Textbox Help
Maybe a shorter alternative ?
Code: Select all
local function split(str, delim)
local splits = {}
for w in str:gmatch('[^'..delim..']+') do splits[#splits+1] = w end
return splits
end
Who is online
Users browsing this forum: Bing [Bot], Google [Bot] and 6 guests