Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   alright how does it work (https://forums.graalonline.com/forums/showthread.php?t=69125)

_Z3phyr_ 10-03-2006 12:51 AM

alright how does it work
 
I see people say prefix.("varname" @ temp.towahth @ "wejthakwlh") = 1;

If this doesn't have anything to do with what I'm about to ask then just pretend I didn't metion it and answer the question anyway:


When you want to declare a value/assign/whatever... nevermind how do I do this:

this.thisismyvarONE = the variable I that I want to edit.

this.varname = "ONE";
this.("thisismyvar" @ this.varname) = 1;


^ please explain how to do because I'm doing it wrong apparently.

Yen 10-03-2006 02:04 AM

What you're doing should work.

fowlplay4 10-04-2006 05:38 AM

You could also do this..
PHP Code:

function onCreated() {
 
this.varname "ONE";
 
makevar("this." this.varname) = 1;
 
chat "this.ONE =" SPC this.ONE;


Its just a matter of personal preference I guess..

xAndrewx 10-04-2006 08:20 AM

Quote:

Originally Posted by fowlplay4 (Post 1225798)
You could also do this..
PHP Code:

function onCreated() {
 
this.varname "ONE";
 
makevar("this." this.varname) = 1;
 
chat "this.ONE =" SPC this.ONE;


Its just a matter of personal preference I guess..

Indeed it is, I'm starting to use makevar, however I prefer to use this.("blah" @ LOLDIE); =(

Skyld 10-04-2006 09:11 AM

Quote:

Originally Posted by xAndrewx (Post 1225827)
Indeed it is, I'm starting to use makevar, however I prefer to use this.("blah" @ LOLDIE); =(

makevar() is untidy and I strongly dislike it when people use it. this.(@ foo) = bar; is the best way in my opinion.

_Z3phyr_ 10-04-2006 09:37 AM

Quote:

Originally Posted by Skyld (Post 1225834)
this.(@ foo) = bar;


So if I'm going to start the variable's name with the value of another variable, I need to use the @ sign to start it off?

this.(@ varname) = value;

The Evil Within 10-04-2006 12:36 PM

I was on RC when you posted this...why didn't you just ask me? Loser.

Although you wouldn't have gotten as good help, I actually like the way Skyld has it formatted better.

Skyld 10-04-2006 04:46 PM

Quote:

Originally Posted by _Z3phyr_ (Post 1225840)
So if I'm going to start the variable's name with the value of another variable, I need to use the @ sign to start it off?

this.(@ varname) = value;

I think you only need it for a variable name only or if a variable name is first.
PHP Code:

this.(@ foo "bar") = baz

However, I do it out of habit even when a string is first. It is probably good practice for consistency and legibility.

Chompy 10-05-2006 12:58 PM

I dunno why people are using makevar :p
-longer too write
-looks more complicated if you ask me, but isn't

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
temp."lol";
  
temp.(@ temp."lipop") = "hmm?";
  
player.chat temp.lollipop;


is lesser to write then:
PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
temp."lol";
  
makevar("temp." temp."lipop") = "hmm?";
  
player.chat temp.lollipop;



xXziroXx 10-06-2006 01:52 PM

Ive actually started to use makevar() instead of var.(more stuff) lately. I like it more now, and it feels more.. organized?

_Z3phyr_ 10-07-2006 01:01 PM

*shrug* anyway instead of making a new thread how about I pose another question?

How does...
PHP Code:

if (playerleaves) { 

... translate into GS2?

I know it ain't
PHP Code:

function onPlayerleaves() { 

so what is it?!

Twinny 10-07-2006 05:35 PM

Quote:

Originally Posted by xXziroXx (Post 1226617)
Ive actually started to use makevar() instead of var.(more stuff) lately. I like it more now, and it feels more.. organized?

I always did var.(@ some @ "thing") but when i saw makevar() I thought i was doing it the wrong way >_<

_Z3phyr_ 10-09-2006 11:26 AM

So... >_>

_Z3phyr_ 10-19-2006 01:20 AM

*9 days later*
You guys suck

excaliber7388 10-19-2006 02:14 AM

nobody knows....

xXziroXx 10-19-2006 09:22 AM

Playerleaves doesnt exist in GS2, but its not hard to script your own version.


PHP Code:

//#CLIENTSIDE
function onPlayerEnters()
{
  if (
player.level != this.levelname && this.levelname != NULL) {
    
//Oh my gosh, the player changed level!
  
}
  
this.levelname player.level;



Skyld 10-19-2006 09:33 AM

player.level.name. :(

xXziroXx 10-19-2006 09:51 AM

Quote:

Originally Posted by Skyld (Post 1233047)
player.level.name. :(

*whistles*

Admins 10-19-2006 02:33 PM

onPlayerLeaves() should work fine, you are sure it is broken ?

xXziroXx 10-19-2006 02:40 PM

Quote:

Originally Posted by Stefan (Post 1233090)
onPlayerLeaves() should work fine, you are sure it is broken ?

Its not even listed on the Wiki.. only the gs1 version of it is.

_Z3phyr_ 10-20-2006 09:11 PM

apparently it doesn't work.


Anyway lets see if yall can redeem yourselves...

Tell me what I did wrong here. Assume temp.entry is a string and that all arrays and/or variables have been declared before this script comes into play.

PHP Code:

    for (i=1;i<=13;i++) {
  if (
server.arrayprefix_(temp.entry "Suffix")[i]!=null) {
    if (
client.array[i]>=server.arrayprefix_(temp.entry "Suffix")[i]) { 


I've tried saying (@temp.entry@"Suffix") but that doens't work either. If that's the correct answer then maybe I mistyped something.



edit
and yes I know I can jsut say server.array >= client.array but that doesn't answer my question.

Riot 10-20-2006 09:48 PM

Quote:

Originally Posted by Stefan (Post 1233090)
onPlayerLeaves() should work fine, you are sure it is broken ?

It works fine.

Quote:

Originally Posted by _Z3phyr_ (Post 1233517)
apparently it doesn't work.


Anyway lets see if yall can redeem yourselves...

Tell me what I did wrong here. Assume temp.entry is a string and that all arrays and/or variables have been declared before this script comes into play.

PHP Code:

    for (i=1;i<=13;i++) {
  if (
server.arrayprefix_(temp.entry "Suffix")[i]!=null) {
    if (
client.array[i]>=server.arrayprefix_(temp.entry "Suffix")[i]) { 


I've tried saying (@temp.entry@"Suffix") but that doens't work either. If that's the correct answer then maybe I mistyped something.



edit
and yes I know I can jsut say server.array >= client.array but that doesn't answer my question.

You would want to do server.("arrayprefix_" @ temp.entry @ "Suffix")[i].

_Z3phyr_ 10-20-2006 10:01 PM

Roger dodger.

_Z3phyr_ 12-19-2006 12:24 AM

Okay and now how do you translate if (mousedown) to GS2 aka if (leftmousebutton) ?

Gambet 12-19-2006 01:31 AM

Quote:

Originally Posted by _Z3phyr_ (Post 1254937)
Okay and now how do you translate if (mousedown) to GS2 aka if (leftmousebutton) ?

PHP Code:

//#CLIENTSIDE
function onMouseDown() {
 switch(
params[0]) {
  case 
"left"
  case 
"right":
  case 
"middle":
  case 
"double"player.chat "You have just pressed the " params[0] @ " mouse button!"; break;
 }



_Z3phyr_ 12-20-2006 01:21 AM

lolz hey again yall I need help with this thing will you please help me??? how do you do this but make it work b/c something is wrong
PHP Code:

function onTimeout() {
  for (
i=0;i<=2;i++) {
    
player.x+=i;
  }
  
this.setTimer(.5);



Gambet 12-20-2006 01:42 AM

Quote:

Originally Posted by _Z3phyr_ (Post 1255495)
dirty showoffs... let's see you show me how to do this


How to make player move in a direction (equivalent to move() command except player instead of NPC)

and don't say
PHP Code:

function onTimeout() {
  for (
i=0;i<=2;i++) {
    
player.x+=i;
  }
  
this.setTimer(.5);




Or why don't you stop trying to hide the fact that you're asking for scripts instead of your little "let's see you show me how to do this" scam?

If you need help, ask, like a normal person.

Andy0687 12-20-2006 09:36 AM

Quote:

Originally Posted by Gambet (Post 1255501)
Or why don't you stop trying to hide the fact that you're asking for scripts instead of your little "let's see you show me how to do this" scam?

Wow what in the world are you on, its obvious he is asking for help with scripts.

Quote:

If you need help, ask, like a normal person.
It appears its normal for him to ask in those more interesting ways just as its normal for you to critisize and arugue with everyone you come in contact with.

_Z3phyr_ 12-20-2006 07:07 PM

quite


anyway, what's the answer again?

Chompy 12-20-2006 08:31 PM

Quote:

Originally Posted by _Z3phyr_ (Post 1255696)
quite


anyway, what's the answer again?

Quote:

Originally Posted by _Z3phyr_ (Post 1255696)
PHP Code:

function onTimeout() {
  for (
i=0;i<=2;i++) {
    
player.x+=i;
  }
  
this.setTimer(.5);



That would increase the player's x with 0, then by 1, and then by 2..

You could try to add a speed variable, instead of adding the variable of the loop, which is being increased,
(because of the loop speed it would be like, 2 forward, then 1, then 2 forward and 1 forward, would look weird)

To make something near the move() command, but to effect the player, I would use cos, sin and getangle

Gambet 12-20-2006 10:00 PM

Quote:

Originally Posted by Andy0687 (Post 1255612)
Rambling



I don't know what his intentions were, but he put it off as a challenge. Sort of like seeing if people know how to do something, without doing it the way he's done it.

That's the only reason I responded the way I did, else, I'd be glad to help.

_Z3phyr_ 12-20-2006 11:49 PM

This stuff
PHP Code:

function onTimeout() {
  for (
i=0;i<=2;i++) {
    
player.x+=i;
  }
  
this.setTimer(.5);


only moves me by whatever i is set to (in this case 0 tiles), so it doesn't work (I said it because it doesn't work -- as a tip that its not the right answer).

And how about an answer in GS2? English doesn't really help me.

godofwarares 12-28-2006 04:00 PM

Quote:

Originally Posted by _Z3phyr_ (Post 1227123)
*shrug* anyway instead of making a new thread how about I pose another question?

How does...
PHP Code:

if (playerleaves) { 

... translate into GS2?

I know it ain't
PHP Code:

function onPlayerleaves() { 

so what is it?!

Since GS2 is function onEVENTNAME(params) {

It would be

PHP Code:

function onPlayerLeaves() {
// ...


Quote:

Originally Posted by _Z3phyr_ (Post 1227123)
I know it ain't
PHP Code:

function onPlayerleaves() { 


It has to be :P
Playerleaves is an event, and read above :P

godofwarares 01-08-2007 09:59 PM

Quote:

Originally Posted by _Z3phyr_ (Post 1255770)
This stuff
PHP Code:

function onTimeout() {
  for (
i=0;i<=2;i++) {
    
player.x+=i;
  }
  
this.setTimer(.5);


only moves me by whatever i is set to (in this case 0 tiles), so it doesn't work (I said it because it doesn't work -- as a tip that its not the right answer).

And how about an answer in GS2? English doesn't really help me.

Why not just do a for loop that increses the player's X position?

Example:

PHP Code:

function onPlayerTouchsMe()
{

  for ( 
0<= 2i++ )
  {

    
player.x++;

  }



Makes much more sense :)


All times are GMT +2. The time now is 02:07 PM.

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