Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-29-2011, 10:17 AM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Var value from var name

PHP Code:
//#CLIENTSIDE
public function getVarFromName(varname) {
  if (
varname.pos(".") == -1) return -1;
  
temp.tokens varname.tokenize(".");
  
temp.objvar = new TStaticVar();
  
temp.objvar.copyfrom((@temp.tokens[0]));
  return 
getSubObj(temp.objvartemp.tokens.subarray(1temp.tokens.size() - 2)).(@temp.tokens[temp.tokens.size() - 1]);
}

public function 
getSubObj(obj,subobjstrarray) {
  if (
subobjstrarray.size()) return getSubObj(obj.(@subobjstrarray[0]), subobjstrarray.subarray(1subobjstrarray.size() - 1));
  else return 
obj;

In 'getVarFromName', the function returns -1 if the input string does not have an object prefix. I would like to return a variable that does not have an object prefix but I am having trouble figuring out how to do so.

this.(@"name"), since there is an object prefix, gives me the correct result. (The name of the weapon)

(@"mousescreenx") gives me 'mousescreenx' as a string.

Is there a solution this problem?
__________________
Reply With Quote
  #2  
Old 01-29-2011, 10:19 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Try makevar:

PHP Code:
//#CLIENTSIDE
function onCreated() {
  echo(
makevar("mousescreenx")); // echos pixel position of mouse on screen

Other makevar example..

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
temp.really.long.var.something "HA";
  
temp.start "temp.really.long.";
  
temp.value makevar(temp.start "var.something");
  echo(
temp.value); // echos "HA"

__________________
Quote:
Reply With Quote
  #3  
Old 01-29-2011, 10:30 AM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Thanks.
__________________
Reply With Quote
  #4  
Old 01-29-2011, 10:36 AM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
What are you doing that requires that functionality though?

Off the top of my head I can only see myself using it in dynamic commands (I.e: /echovar varname).
__________________
Quote:
Reply With Quote
  #5  
Old 01-29-2011, 10:45 AM
0PiX0 0PiX0 is offline
Coder
0PiX0's Avatar
Join Date: Jan 2011
Posts: 130
0PiX0 is a jewel in the rough0PiX0 is a jewel in the rough
Quote:
Originally Posted by fowlplay4 View Post
What are you doing that requires that functionality though?
Nothing in particular. I see no documentation on makevar, and I did not know it existed. So I recreated it for scripting practice and any possible future use.
__________________
Reply With Quote
  #6  
Old 01-29-2011, 09:59 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
i've never used makevar myself, may i ask what's the difference?
PHP Code:
makevar("this.foo_bar") = "var"
or
PHP Code:
this.(@"foo_bar") = "var"
just for the sake of future reference'
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #7  
Old 01-29-2011, 10:37 PM
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
Quote:
Originally Posted by Deas_Voice View Post
i've never used makevar myself, may i ask what's the difference?
PHP Code:
makevar("this.foo_bar") = "var"
or
PHP Code:
this.(@"foo_bar") = "var"
just for the sake of future reference'
There is essentially no difference except that sometimes you can't use the second example and have to use makevar (I think variables that don't have a prefix/object?). Avoid makevar if possible.
__________________
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 04:07 AM.


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