Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Integer? (https://forums.graalonline.com/forums/showthread.php?t=50183)

GoZelda 01-05-2004 07:18 PM

Integer?
 
How do you make a certain value an integer?

Loriel 01-05-2004 07:24 PM

NPC Code:
if (int(5.5) == 5) message w00t!;


... ?

GoZelda 01-05-2004 07:43 PM

More like this:

NPC Code:

this.value=65.495303;
int(this.value);
//this.value=65



I found it out, thx to Giltwist

NPC Code:

setstring clientr.hp,#v(int(random(25,100)));


Loriel 01-05-2004 07:46 PM

Pft, that is what I said, but, still...
Quote:

Originally posted by GoZelda
NPC Code:

this.value=65.495303;
int(this.value);
//this.value=65


NPC Code:



Untrue.

GoZelda 01-05-2004 07:53 PM

Quote:

Originally posted by Loriel
Pft, that is what I said, but, still...
Untrue.

It was and example... I know it doesn't work :|

Ningnong 01-05-2004 09:32 PM

you meant this ?

NPC Code:

this.value = 65.75345;
this.newvalue = int(this.value);
message #v(this.newvalue);



etc..

GoZelda 01-05-2004 10:05 PM

No, i meant

this.i=64.03048487529532
int(this.i);
And the solution would be 64... But that didn't work, i must do
this.i=64.03048487529532
this.j=int(this.i);

Hevaricubed 01-05-2004 10:11 PM

Yeah graal functions dont assign values by reference.

e.g. In VB:

Private Sub Form_Load()
Dim x as integer
funcByValue x
MsgBox x
End Sub

Function funcByValue(ByVal x As Integer)
x = 10
End Function

At the end of this program, it would msgbox 0

Private Sub Form_Load()
Dim x as integer
funcByReference x
MsgBox x
End Sub

Function funcByReference(ByRef x As Integer)
x = 10
End Function

At the end of this program, it would msgbox 10.

Graal functions have parameters and return the values of what the functions return through the function, not the parameters.

therefore

this.i=64.3125325123551235;
int(this.i);
//this.i==64.3125325123551235

but

this.i=64.3125325123551235;
this.i=int(this.i);
//this.i==64

At this point i have hopefully confused the hell out of anyone and if not, bluegh :P

:D

GoZelda 01-05-2004 10:29 PM

In nearly every programming language you must assign a value to a certaintype :o

Loriel 01-05-2004 10:40 PM

Quote:

Originally posted by GoZelda
In nearly every programming language you must assign a value to a certaintype :o
In C++ you can have a function like Int that will set a foo = 5.5 to 5 if you do Int(foo);. No need for for foo = Int(foo);.

GoZelda 01-05-2004 10:48 PM

I thought the you was C--

DIABLO2099 01-05-2004 10:58 PM

Quote:

Originally posted by Loriel

In C++ you can have a function like Int that will set a foo = 5.5 to 5 if you do Int(foo);. No need for for foo = Int(foo);.

Yeah, defining function types is a plus in my eyes. Although this topic is not really about C++, when a function has to return a string value, you define the function as string? I haven't learned fully about strings yet but I like to stay ahead of everyone.

Ningnong 01-05-2004 11:09 PM

Quote:

Originally Posted By GoZelda
No, i meant

this.i=64.03048487529532
int(this.i);
And the solution would be 64... But that didn't work, i must do
this.i=64.03048487529532
this.j=int(this.i);

Yes, thats what I just done... in my example, this.newvalue is the solution, it is an integar made from this.value.

You just used different letters O_o ..

Loriel 01-05-2004 11:47 PM

Quote:

Originally posted by DIABLO2099
when a function has to return a string value, you define the function as string?
Yes, but I suggest not doing that.

Coding in C++ I mean.


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

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