Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-05-2004, 07:18 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
Integer?

How do you make a certain value an integer?
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #2  
Old 01-05-2004, 07:24 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
NPC Code:
if (int(5.5) == 5) message w00t!;


... ?
Reply With Quote
  #3  
Old 01-05-2004, 07:43 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
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)));

__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #4  
Old 01-05-2004, 07:46 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
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.
Reply With Quote
  #5  
Old 01-05-2004, 07:53 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
Quote:
Originally posted by Loriel
Pft, that is what I said, but, still...
Untrue.
It was and example... I know it doesn't work :|
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #6  
Old 01-05-2004, 09:32 PM
Ningnong Ningnong is offline
Registered User
Ningnong's Avatar
Join Date: Nov 2002
Location: < -- way
Posts: 262
Ningnong is on a distinguished road
you meant this ?

NPC Code:

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



etc..
__________________
Former Global Scripting Team Member


Reply With Quote
  #7  
Old 01-05-2004, 10:05 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to 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);
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #8  
Old 01-05-2004, 10:11 PM
Hevaricubed Hevaricubed is offline
Registered User
Join Date: Aug 2003
Posts: 262
Hevaricubed is on a distinguished road
Send a message via AIM to Hevaricubed Send a message via Yahoo to Hevaricubed
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

__________________
Reply With Quote
  #9  
Old 01-05-2004, 10:29 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
In nearly every programming language you must assign a value to a certaintype :o
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #10  
Old 01-05-2004, 10:40 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
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);.
Reply With Quote
  #11  
Old 01-05-2004, 10:48 PM
GoZelda GoZelda is offline
Mister 1,000,000
GoZelda's Avatar
Join Date: Jan 2003
Location: Brussels, capital of Europe.
Posts: 5,396
GoZelda will become famous soon enough
Send a message via AIM to GoZelda Send a message via MSN to GoZelda
I thought the you was C--
__________________

Quote:
Originally Posted by Lance
stefan is satan
I am the best.
[URL removed]Music or aural pollution?
Reply With Quote
  #12  
Old 01-05-2004, 10:58 PM
DIABLO2099 DIABLO2099 is offline
Registered User
Join Date: Sep 2002
Location: New York
Posts: 290
DIABLO2099 is on a distinguished road
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.
__________________
-Former UnholyNation Server Manager.

Call me Xecutor.
Reply With Quote
  #13  
Old 01-05-2004, 11:09 PM
Ningnong Ningnong is offline
Registered User
Ningnong's Avatar
Join Date: Nov 2002
Location: < -- way
Posts: 262
Ningnong is on a distinguished road
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 ..
__________________
Former Global Scripting Team Member


Reply With Quote
  #14  
Old 01-05-2004, 11:47 PM
Loriel Loriel is offline
Somewhat rusty
Loriel's Avatar
Join Date: Mar 2001
Posts: 5,059
Loriel is a name known to allLoriel is a name known to allLoriel is a name known to allLoriel is a name known to all
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.
Reply With Quote
Reply


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:39 PM.


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