Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 11-20-2013, 09:24 PM
cyan3 cyan3 is offline
Registered User
cyan3's Avatar
Join Date: Nov 2005
Location: England
Posts: 2,919
cyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant future
Quote:
Originally Posted by iDigzy View Post
Hi, I recently started scripting GS2 and I have a few questions.
1. What are classes for, like difference between weapons?
2. What is the point of npc's option when you can add npc's in level editor? Is it the same?
3. For setting things for a player, for example the hat or head would the script be something like player.attr1 = "filename"?
4. Are there any "and" or "or" words that can be used in an if statement? For example, a script like
function onPlayerchats() {
if (player.chat = "hello") *could you put an "and" or an "or" comparison here?* {
player.chat = "hi"
}
Classes are used to minimize code reuse and helps improve debugging/maintenance of your code as you'd only have to edit the single class to apply the changes to every script that uses that class. For example, you could have a class that handles damage which could then be called from any weapon script when you need to cause damage to a player instead of rewriting that same code in every weapon script.

It would be player.attr[1] = "filename";

and is && and or is ||

For example:

PHP Code:
function onPlayerChats() {

    if (
player.chat == "hello" || player.chat == "bye") {

        
player.chat "hi";
    }

Also if you are checking a value is equal to something please use the == operator instead of =, Although both work in GS2 it is good practice to use == for equality and = for assignment.

Last edited by cyan3; 11-20-2013 at 09:45 PM..
Reply With Quote
 


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 05:56 PM.


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