Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-11-2012, 04:42 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Question regarding GuiTextEditCtrl

Basically I am working on a trade system.
I want to make it so that if you enter a character that isn't a number it will remove it. I have made the detection weather it is a number or not but how would I remove the last character of the textedit control?
I have tried a few things, such as:
PHP Code:
Trade_MyGralats.text.length() -= 1;
Trade_MyGralats.text.size() -= 1;
Trade_MyGralats.text -= 1
But none of them work, Thanks in advanced.
I was also thinking maybe it would have something to do with .pos() Not sure though.
Maybe this is an idea for a future improvement for text controls.
PHP Code:
allowedcharactersonly true;
allowedcharacters= { "a""b""c" }; 
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #2  
Old 01-11-2012, 05:07 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
PHP Code:
Trade_MyGralats.text.length() -= 1;
Trade_MyGralats.text.size() -= 1
These make no sense, the return value of a function is not a variable.

PHP Code:
Trade_MyGralats.text -= 1
text is a string, not a number, so this isn't going to work either.

PHP Code:
Trade_MyGralats.text Trade_MyGralats.text.substring(0Trade_MyGralats.text.length() - 1); 
substring is the key. Probably you'd be better off just saving a copy of the old string (before letters were added) and then changing the text back to the old string if they enter a letter. Right now someone could just enter a letter anywhere but the end of the string and it wouldn't fix this.
__________________
Reply With Quote
  #3  
Old 01-11-2012, 08:03 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
Ahok. So when there is a keydown if they don't press a letter save temp.text, then if they press a letter change the text to temp.text, shoulda thought of that, thanks.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
  #4  
Old 01-11-2012, 10:46 AM
Mark Sir Link Mark Sir Link is offline
Kevin Azite
Mark Sir Link's Avatar
Join Date: Sep 2005
Posts: 1,489
Mark Sir Link is just really niceMark Sir Link is just really nice
Send a message via AIM to Mark Sir Link
the real solution though is to just have the guitexteditctrl use its own profile and change profile.numbersonly to true.
Reply With Quote
  #5  
Old 01-11-2012, 11:16 AM
Gunderak Gunderak is offline
Coder
Gunderak's Avatar
Join Date: Jun 2011
Location: Australia
Posts: 795
Gunderak is on a distinguished road
O_o That seems a lot simpler.
Does it allow to copy and paste though? Because I didn't want to allow copy and pasting.
__________________

Gund for president.

Remote PM {P*}x (Graal813044) from eraiphone -> Stefan: I hav 1 qustion
*Gunderak: he hav 1
*Gunderak: qustion
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.