Thanks for the help!
I used sub like this:
Code: Select all
text = string.sub(text, 0, (string.len(text)-1))
I thought sub(text, 0, -1) might work as a shorter way, but that didn't seem to do anything.
btw, as for the switch, I think it's a lot eaiser to read than ifs and elseifs.
I've changed my code to have the defaul case do nothing, and I added cases for each letter instead. So here's how it looks:
Code: Select all
[love.key_a] = function (x) return letter(x) end,
[love.key_b] = function (x) return letter(x) end,
[love.key_c] = function (x) return letter(x) end,
[love.key_d] = function (x) return letter(x) end,
[love.key_e] = function (x) return letter(x) end,
[love.key_f] = function (x) return letter(x) end,
[love.key_g] = function (x) return letter(x) end,
[love.key_h] = function (x) return letter(x) end,
[love.key_i] = function (x) return letter(x) end,
[love.key_j] = function (x) return letter(x) end,
[love.key_k] = function (x) return letter(x) end,
[love.key_l] = function (x) return letter(x) end,
[love.key_m] = function (x) return letter(x) end,
[love.key_n] = function (x) return letter(x) end,
[love.key_o] = function (x) return letter(x) end,
[love.key_p] = function (x) return letter(x) end,
[love.key_q] = function (x) return letter(x) end,
[love.key_r] = function (x) return letter(x) end,
[love.key_s] = function (x) return letter(x) end,
[love.key_t] = function (x) return letter(x) end,
[love.key_u] = function (x) return letter(x) end,
[love.key_v] = function (x) return letter(x) end,
[love.key_w] = function (x) return letter(x) end,
[love.key_x] = function (x) return letter(x) end,
[love.key_y] = function (x) return letter(x) end,
[love.key_z] = function (x) return letter(x) end,
Now imagine that with ifs and elseifs
Okay, now for the hard part... Navigating text with the arrow keys...
Does anybody have any clue how to do this? I don't have any ideas on this one.
I currently store all the text as a single string... was that a bad start? Does it make navigating the text really difficult?
EDIT: Actually, I figured it out! Also using string.sub
Although, you can only navigate left and right.
I've attached the love file so you can see what I've got so far. I would love any suggestions you might have.
- createlove011.love
- Create Love v0.1.1 - text editor made with Love
- (20.13 KiB) Downloaded 549 times
What I want to add next is getting symbols (punctuation) to work...
I still have a question from my original post:
Oh wait, I notice that there are also constants for exclamation marks, question marks, etc. When are these constants returned?
Because when I use the keypressed() function, and I press 'shift+1', I get a 'shift' and a '1' returned, not a '!'.