Jump to content




Backspace


  • You cannot reply to this topic
11 replies to this topic

#1 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 06 August 2012 - 06:14 AM

How would one remove a letter from the string in a table
Example
tHistory = {}
tHistory[1] = ""
h = 1

if key == 14 then tHistory[h] = "" ..tHistory[h].. " " end


#2 ChiknNuggets

  • Members
  • 130 posts

Posted 06 August 2012 - 06:34 AM

i cant see exactly where in your code you would want this but basically just do
tHistory[h] = string.sub(tHistory[h], 1, -2)


#3 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 06 August 2012 - 06:35 AM

Nvm..
For future solutions: string.sub works
tHistory[h] = string.sub(tHistory[h], 1, string.len(tHistory[h]) - 1 )


#4 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 06 August 2012 - 06:37 AM

View PostChiknNuggets, on 06 August 2012 - 06:34 AM, said:

i cant see exactly where in your code you would want this but basically just do
tHistory[h] = string.sub(tHistory[h], 1, -2)
Want to see my code?
Spoiler
Its virtual console.
EDIT: Caps and other grammar things not working yet.

#5 ChiknNuggets

  • Members
  • 130 posts

Posted 06 August 2012 - 07:38 AM

ahh thats incredibly overly needed line wise

#6 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 06 August 2012 - 08:00 AM

why all of the code? you should just pick it up as normal and then say

if key~="backspace" and key~="enter" then -- and keep doing that to leave out irregular keys
tHistory[h]=""..tHistory[h]..key
end

that way it adds caps and lowercase fine and just leaves out the keys that aren't chars

#7 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 06 August 2012 - 08:13 AM

I tried that earlier (above) it works, but this looks so much cooler. Having thousands of lines of if statements.. lmao.
IDK, It'll show my hard work (IN NPP).
EDIT: It's weird, I have to block key lshift and rshift.
EDIT: Caps don't work.

#8 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 06 August 2012 - 01:22 PM

yeah, you have to block any key that cc recognises as an event that does not enter in a character, there is of course a very simple way to do it, just return the length of 'key' and only add it to tHistory if it is 1 character long...

#9 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 06 August 2012 - 01:23 PM

because anything that is not a typable character has a key description and that is always at least 3 chars long

#10 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 06 August 2012 - 01:25 PM

then you add arrow key, enter and backspace/delete functionality and you have a functioning input receiver

the problem is while you have no doubt put a lot of work into writing all of those if statements the PC now has to put that much effort into reading it every time you press a key, this drastically slows things down

#11 Noodle

  • Members
  • 989 posts
  • LocationSometime.

Posted 06 August 2012 - 01:49 PM

Why do you triple post?

#12 KaoS

    Diabolical Coder

  • Members
  • 1,510 posts
  • LocationThat dark shadow under your bed...

Posted 06 August 2012 - 02:07 PM

sorry about that :P/> I'm really busy at the moment so can't concentrate





2 user(s) are reading this topic

0 members, 2 guests, 0 anonymous users