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-16-2010, 02:27 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
textWidth help o.o

PHP Code:
function showInterfaceButtons() {
  
temp.buttontext = {"New Scene""Save Scene""Load Scene""Help"};

  
temp.dx 4;

  for (
temp.i=0;temp.i<2;temp.i++) {
    
this.images++;
    
showText(this.imagestemp.dx4"Tahoma""i"temp.buttontext[temp.i]);
    
changeImgVis(this.images6);

    
this.images++;
    
showText(this.imagestemp.dx+26"Tahoma""i"temp.buttontext[temp.i]);
    
changeImgVis(this.images5);
    
changeImgColors(this.images0.250.250.251);

    
temp.dx += textwidth(1"Tahoma""i"temp.buttontext[temp.i]);
  }

Can somebody explain why that doesn't work correctly?

It's supposed to display them in order from left to right with the correct spacing in between. Doesn't work properly, unfortunately. TextWidth seems to be bugged up, unless, of course, I'm using it improperly.
Reply With Quote
  #2  
Old 01-16-2010, 02:30 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
The correct function name would be 'gettextwidth'.
Reply With Quote
  #3  
Old 01-16-2010, 02:36 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Thank you.
Reply With Quote
  #4  
Old 01-16-2010, 03:05 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Does anybody know the equivalent of setArray for GS2?
Reply With Quote
  #5  
Old 01-16-2010, 03:14 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by 12171217 View Post
Does anybody know the equivalent of setArray for GS2?
this.array = new[#];
Reply With Quote
  #6  
Old 01-16-2010, 03:20 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Quote:
Originally Posted by xXziroXx View Post
this.array = new[#];
Fabulous. Thanks again.

Another question; I'm a GS1 buff, not a GS2 buff

Can you create entirely new objects, and arrays of objects in GS2?
Reply With Quote
  #7  
Old 01-16-2010, 03:23 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by 12171217 View Post
Can you create entirely new objects, and arrays of objects in GS2?
Yes.
Reply With Quote
  #8  
Old 01-16-2010, 03:39 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Quote:
Originally Posted by xXziroXx View Post
Yes.
And the syntax would be? o.o
Reply With Quote
  #9  
Old 01-16-2010, 03:50 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by 12171217 View Post
And the syntax would be? o.o
Depends what you mean by "creating new objects" really. But, something along these lines:

PHP Code:
this.array = new[0];
this.array.add(this);  // Would add the current object into the array
this.array.add(findPlayer("xXziroXx"));  // Would add the player object (if online)

// The following example is the same as the above.

this.array = { thisfindPlayer("xXziroXx") };  // Would create a two sized array with the current object, as well as the object found by the findPlayer() function. 
Was that what you were looking for?
Reply With Quote
  #10  
Old 01-16-2010, 03:57 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Quote:
Originally Posted by xXziroXx View Post
Depends what you mean by "creating new objects" really. But, something along these lines:

PHP Code:
this.array = new[0];
this.array.add(this);  // Would add the current object into the array
this.array.add(findPlayer("xXziroXx"));  // Would add the player object (if online)

// The following example is the same as the above.

this.array = { thisfindPlayer("xXziroXx") };  // Would create a two sized array with the current object, as well as the object found by the findPlayer() function. 
Was that what you were looking for?
I meant it as far as doing something along the lines of defining data structures in C++.

PHP Code:
typedef struct {
  
float xyz;
3dpoint;

3dpoint cheeselocation;

cheeselocation.1;
cheeselocation.2;
cheeselocation.3
Can you do anything along the lines of that in GS2?
Reply With Quote
  #11  
Old 01-16-2010, 04:05 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
You can be lazier!

PHP Code:
function onCreated() {
  
temp.obj = new TStaticVar();
  
temp.obj.1;
  
temp.obj.2;
  
temp.obj.3;

__________________
Quote:
Reply With Quote
  #12  
Old 01-16-2010, 04:07 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
I'm not really familiar with C++ (or many other languages), but if that's supposed to do what I think it is, the closest you'd find would be something like this:

PHP Code:
this.myobject = new TStaticVar("cheeselocation");

cheeselocation.foo "bar"
Reply With Quote
  #13  
Old 01-16-2010, 04:08 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Quote:
Originally Posted by fowlplay4 View Post
You can be lazier!

PHP Code:
function onCreated() {
  
temp.obj = new TStaticVar();
  
temp.obj.1;
  
temp.obj.2;
  
temp.obj.3;

Haha, perfect, thanks.
Reply With Quote
  #14  
Old 01-16-2010, 04:34 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
You can't make actual objects/object types, whatever you want to call them, but you can make TStaticVars, set variables, and join classes to them to do most of what you probably want to do.

PHP Code:
//#CLIENTSIDE
function onCreated() {
  
CheeseLocation = new TStaticVar();
  
CheeseLocation.join("CheeseLocation");

and in the class CheeseLocation:

PHP Code:
//#CLIENTSIDE
public function setPosition(xyz) {
  
this.position = {xyz};
}

public function 
getPosition() {
  return 
this.position;
}

// you can even do this to spoof it as an object even further, but there's no real reason to
public function objectType() {
  return 
"CheeseLocation";

Keep in mind there will be a delay between the time obj.join() is called and when the class is actually joined (it doesn't pause the script to wait for it to join).

You can also make new instances of the object you made.

PHP Code:
BigCheese = new CheesePosition();
BigCheese.setPosition(130);

SmallCheese = new CheesePosition();
SmallChese.setPosition(041); 
A bit of a workaround but it works.

EDIT: oops, didn't notice the second page of the thread
__________________
Reply With Quote
  #15  
Old 01-16-2010, 04:40 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Thanks anyway, Chris. I appreciate it regardless.
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:37 PM.


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