Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Simple command Questions (https://forums.graalonline.com/forums/showthread.php?t=64724)

Wryoko 03-13-2006 01:37 PM

Simple command Questions
 
I'm new to Gscripting and now that theres a second version.. Well I'm very lost =X
Anyway, I'm trying to get a npc to display a simple line of text so that I may use it for other scripts. However, the ones I've tried won't work online. I need to figure this out so I can learn how to use classes and make basic programs like a calculator. So what command should I use o.o showtext(); and if so could you provide a usage example?

Projectshifter 03-13-2006 07:44 PM

Quote:

Originally Posted by Wryoko
I'm new to Gscripting and now that theres a second version.. Well I'm very lost =X
Anyway, I'm trying to get a npc to display a simple line of text so that I may use it for other scripts. However, the ones I've tried won't work online. I need to figure this out so I can learn how to use classes and make basic programs like a calculator. So what command should I use o.o showtext(); and if so could you provide a usage example?

There is the ever popular obj.chat var, but for showtext() it's basically like it was before, and if you need further help with that, I point you to the Wiki, that's what it's there for :)

jake13jake 03-13-2006 09:28 PM

Quote:

Originally Posted by Wryoko
I'm new to Gscripting and now that theres a second version.. Well I'm very lost =X
Anyway, I'm trying to get a npc to display a simple line of text so that I may use it for other scripts. However, the ones I've tried won't work online. I need to figure this out so I can learn how to use classes and make basic programs like a calculator. So what command should I use o.o showtext(); and if so could you provide a usage example?

Take a dive into object oriented programming and then you might be able to better understand ;P

Wryoko 03-14-2006 03:15 AM

Quote:

Originally Posted by jake13jake
Take a dive into object oriented programming and then you might be able to better understand ;P

Oh I have. I learned enough java to go through a script and understand the overall flow. I've printed out tutorials from Wiki and have been studying them for about four or five days now. However I learn better when I see a script, that isn't out dated and that I'm able to tweak and chop up to use in other scripts. I know it seems as if I'm just another one of those people looking for an easy script for their server, but I'm honestly trying to learn how to do this on my own.

What I was planning on doing, was using that basic script hopefully provided to me, and use it to make a class. Basically, I'm trying to store a few variables (name, age, and a list of items; the different kinds of vars) and provide functions that would allow me to call for the display of them. Eventually I would provide functions to allow me to change the vars in game and create instances of that template. I'm just trying to get used to the overall format and usage.

Wryoko 03-14-2006 03:16 AM

I've also taken the list of updated commands and have been organizing them in a logical order; like the packages in java. That way I'll be able to remember them with ease.

jake13jake 03-14-2006 03:35 AM

Quote:

Originally Posted by Wryoko
I've also taken the list of updated commands and have been organizing them in a logical order; like the packages in java. That way I'll be able to remember them with ease.

You could probably do that directly on the wiki too.

Wryoko 03-14-2006 04:06 AM

Quote:

Originally Posted by jake13jake
You could probably do that directly on the wiki too.

Uh I got it from wiki. Well the newly implemented commands are together and all but the old ones aren't as much as I'd like.

Projectshifter 03-14-2006 04:17 PM

Quote:

Originally Posted by Wryoko
Oh I have. I learned enough java to go through a script and understand the overall flow.

Think java without the datatypes, and without privitized vars. The new engine is fun =)

Codein 03-14-2006 08:11 PM

Aye, when learning Java, I was in awe at how much GS2 resembled it.

jake13jake 03-14-2006 10:24 PM

I prefer C++ because it's not as strongly typed, although I'd prefer the Java syntax.

Projectshifter 03-15-2006 04:18 AM

Quote:

Originally Posted by jake13jake
I prefer C++ because it's not as strongly typed, although I'd prefer the Java syntax.

I dunno, I'd argue that they're both equally typed, and perhaps C++ would beat it out a bit considering that it runs at a much lower level and has access to things such as pointers etc. Java sucks =(

Zero Hour 03-15-2006 06:34 AM

Quote:

Originally Posted by Projectshifter
I dunno, I'd argue that they're both equally typed, and perhaps C++ would beat it out a bit considering that it runs at a much lower level and has access to things such as pointers etc. Java sucks =(

Call me a newb, and paint me green - but couldn't you make some sort of mad C++ DLL that java could use?

jake13jake 03-15-2006 08:31 PM

Java's arrays are like a class with a read-only size variable. You can't go out of bounds in a Java array. The size variable is nice, but you can make a list class in C++ that would be better than a Java array because in C++ you can override certain operators and in Java you can't override any operators. In Java you can't have two derived class types and in C++ you can. Java is more strongly typed to better guard against security holes. Java has the built in garbage collector thing and C++ doesn't. Java's syntax has a much nicer structure and promotes readability more than C++. In my opinion, Java's library overstates readability in the sense that it makes things less readable sometimes, but any programmer can do that. Also, Java is platform independent. My thumb is bleeding.

Loriel 03-16-2006 01:34 AM

Quote:

Originally Posted by Zero Hour
Call me a newb, and paint me green - but couldn't you make some sort of mad C++ DLL that java could use?

You can!

Java methods can be declared "native" which means that they are not implemented in Java but in an external library, in regular machine code. You can then have a program generate a C header file with the C counterparts to the native function's declaration, and then you can implement the functions. The implementation can be in C++ (as long as you do the whole extern "C" thing or in Pascal or ASM or whatever as long as the functions use the expected calling conventions.

Yeah, it is not generally something you want to do all the time, even if you have an existing C++ library, you need to write special wrappers in C and in Java to be able to use it from Java.

Projectshifter 03-17-2006 12:41 AM

Quote:

Originally Posted by jake13jake
Java's syntax has a much nicer structure and promotes readability more than C++. In my opinion, Java's library overstates readability in the sense that it makes things less readable sometimes, but any programmer can do that. Also, Java is platform independent.

I dislike using the term platform independent because it implies that you have the Java VM installed, but by the same token you can use GTK+ or SDL/OpenGL etc and have the same level of platform independency as you have with Java. Granted you'd have different binaries for each platform, but at the same time they are actually executable and don't require it to feed everything through the Java VM.

Java is basically simpler than C++, and it has a ****ton of pre-written libraries, which is both good and bad. Personally if you're going to write something that you're going to use or distribute I think it makes much more sense to do it in C/C++ if you are capable.

Also about the Arrays, Java has ArrayLists I believe which do not have to be defined as a certain length. I think the concept of arrays that cannot change sizes is kind of defeating. It has a few practical uses but it seems to be more of a hassle than it is worth. 99.9% of the time that I use arrays it's dynamic and I am not sure of how many elements it has to it. I just don't like Java overall, I hardly show up to my Java class anymore =/ My professor was going to let me test out of both of the java programming classes we have here but she wasn't going to give me credits. Oh well, easy A's are easy A's.

jake13jake 03-17-2006 02:52 AM

Projectshifter, ArrayLists are obviously dynamically allocated and mutable with the class doing the memory allocation for you. Normal arrays must have a predetermined length, and you cannot change that length. It's like having String and StringBuffer, and I don't like having to type out StringBuffer.

Loriel 03-17-2006 05:29 PM

Quote:

Originally Posted by Projectshifter
I think the concept of arrays that cannot change sizes is kind of defeating.

The anytype[] classes in Java are not meant to be actually used as arrays. They are primarily meant to implement array classes, and to provide some lowlevel aggregate data structure.

C++ arrays are as unresizable as Java arrays.

jake13jake 03-17-2006 06:28 PM

Quote:

Originally Posted by Loriel
The anytype[] classes in Java are not meant to be actually used as arrays. They are primarily meant to implement array classes, and to provide some lowlevel aggregate data structure.

C++ arrays are as unresizable as Java arrays.

What's fun in C++ though, is that you can override the [] operator with classes so you can make a list class that uses the the [] for indicating index, and then add or remove from the list and the size auto adjusts... fun.

Loriel 03-17-2006 09:15 PM

Quote:

Originally Posted by jake13jake
What's fun in C++ though, is that it puts a lot of effort to enable you to make user-defined types be usable like primitive types

I totally agree.


All times are GMT +2. The time now is 11:16 PM.

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