Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   GuiTextEditCtrl assigning and showing variables help (https://forums.graalonline.com/forums/showthread.php?t=134266223)

Devil_Lord2 04-12-2012 03:04 AM

GuiTextEditCtrl assigning and showing variables help
 
1 Attachment(s)
How do I make a gui text a string?
Where as client.intro = 5;
Dev_Client_Var = "client.intro";

function Dev_Client_OK.onAction(){
(""@"player."@Dev_Client_Var.text) = 15;
}

I want player.client.intro = 15;
But I can't seem to do it..
It either says 5, or 0..

I've been messing around with it... Not sure what to do.

PHP Code:

function Dev_Client_OK.onAction(){
//player.Dev_Client_Var.text = 15;
  
player.chat "player."@Dev_Client_Var.text;
  
sleep(1); 
  
player.chat "player."(""@Dev_Client_Var.text);
  
sleep(1);
//(""@Dev_Client_Var.text = Dev_Client_NewVar.text; 


Yet I can't even get this to show it as a string.
player.client.intro = 15;
instead it is basically doing 5 = 15... Which doesn't make sense. :p

Gunderak 04-12-2012 09:03 AM

Have you tried something like this?
PHP Code:

  player.(@Dev_Client_Var.text); 


Emera 04-12-2012 12:19 PM

You've set Dev_Client_Var to client.intro, so why are you doing Dev_Client_Var.text?
PHP Code:

//#CLIENTSIDE

function onCreated() {
  var = 
"hello";
  
player.chat = var;
  
//not player.chat = var.text


edit:
Wait, is Dev_Client_Var a GUI text ctrl?

PHP Code:

new GuiTextCtrl("Dev_Client_Var") {
  
//all this x and y crap
  
var = client.intro;
}

new 
GuiButtonCtrl("Dev_Client_OK") {
  
//all this x and y crap
}

function 
Dev_Client_OK.onAction() {
  
//Are you trying to make it trad Dev_Client_Var.var?
  
player.chat "player." Dev_Client_Var.var;


I'm trying to understand what you're trying to do here but what you just posted didn't make a lot of sense to me.

Devil_Lord2 04-12-2012 02:22 PM

Quote:

Originally Posted by Emera (Post 1691851)
You've set Dev_Client_Var to client.intro, so why are you doing Dev_Client_Var.text?
PHP Code:

//#CLIENTSIDE

function onCreated() {
  var = 
"hello";
  
player.chat = var;
  
//not player.chat = var.text


edit:
Wait, is Dev_Client_Var a GUI text ctrl?

PHP Code:

new GuiTextCtrl("Dev_Client_Var") {
  
//all this x and y crap
  
var = client.intro;
}

new 
GuiButtonCtrl("Dev_Client_OK") {
  
//all this x and y crap
}

function 
Dev_Client_OK.onAction() {
  
//Are you trying to make it trad Dev_Client_Var.var?
  
player.chat "player." Dev_Client_Var.var;


I'm trying to understand what you're trying to do here but what you just posted didn't make a lot of sense to me.

Yes, it is a GUI text ctrl, I was helped by the first part with Thyme (looking back I wouldn't have been able to do it my self) Took him about 20 minutes to figure it out. Now I'd like the input of the GUI to be able to set the variable...

You input the variable name in the left input i.e.: "client.intro"
then in the right input you would put in the number or array
i.e.: 5 or {6,4,2} or "testing"...

Emera 04-12-2012 02:36 PM

Quote:

Originally Posted by Devil_Lord2 (Post 1691855)
Yes, it is a GUI text ctrl, I was helped by the first part with Thyme (looking back I wouldn't have been able to do it my self) Took him about 20 minutes to figure it out. Now I'd like the input of the GUI to be able to set the variable...

You input the variable name in the left input i.e.: "client.intro"
then in the right input you would put in the number or array
i.e.: 5 or {6,4,2} or "testing"...

client.intro = controlname.text;

Devil_Lord2 04-12-2012 03:33 PM

Visual Example
 
If no one can understand this, I don't know what people will.
I tried to have it just equal 15 (so I really didn't have to keep typing it)
This should show visually what I'm trying to do.

Input1 assigns Input2 to itself.
PHP Code:

input1 Client Variable
input2 
Client NewVar

Type in 
"client.intro" to input1  (Automatically adds player.)
input1 client.intro;

Type in "15" to input2
input2 
15;

input1 input2;
input1 "player.client.intro" 15
   
However:
player.client.intro != 15;  
Something is going wrong, and it isn't assigning or seeing player.client.intro as a real variable.. 


Later I'll have to do:
if (input1 == null){
return;
}
So that if there is no such thing as client.intro, it wouldn't do anything.



I've tried this too:
PHP Code:

function Dev_Client_OK.onAction(){
  
temp.obj = new TStaticVar();
  
temp.obj.newVar "player."@Dev_Client_Var.text;
  
player.chat "Input box: "@obj.newVar;
  
sleep(3);
  @
obj.newVar 15;
  
player.chat "@obj.newVar:"SPC obj.newVar SPC "should be 15";
  
sleep(3);
  
player.chat "In reality it is:" SPC player.client.intro;
  
temp.obj.destroy();


Basically you see "Input box: player.client.intro" then
"@obj.newVar: player.client.intro should be 15", then
"In reality it is: 5" since my client.intro is 5 and hasn't
changed.

Gunderak 04-12-2012 06:13 PM

I don't really understand but I think you could just do for the input null part:
PHP Code:

  if(!input) return; 


Devil_Lord2 04-12-2012 06:24 PM

Quote:

Originally Posted by Gunderak (Post 1691874)
I don't really understand but I think you could just do for the input null part:
PHP Code:

  if(!input) return; 


The only reason why I can't do this ... well I can do it but still need the other part is
someone might put client.peanuts = 12 in the input..

Well if the variable 'peanuts' does not exist, it probably shouldn't be used lol...




So it will still have an input but that isn't the question right now but is for the second part, thank you for attempting to help!! Not quite what I was going for though.

I might have to have it search through the clients current strings/variables that exist...

fowlplay4 04-12-2012 11:22 PM

You're looking for makevar. Avoid using 'var' by itself as a variable name.

I.e.

PHP Code:

function setVar(varivalue) {
  
makevar(vari) = value;


then in your code when the button is clicked..

PHP Code:

function Dev_Client_OK.onAction(){
  
setVar(Dev_Client_Var.textDev_Client_NewVar.text);



Devil_Lord2 04-12-2012 11:26 PM

I need to spread rep before I positive rep you again. Thank you so freaking much.
I don't think the problem was exactly others couldn't understand it, I think they just couldn't do it therefor not comprehending what was supposed to be done.

The video it self should have explained it... regardless you've done it!


All times are GMT +2. The time now is 07:03 AM.

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