Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   New Scripter On The Block :) (https://forums.graalonline.com/forums/showthread.php?t=67360)

killerogue 07-14-2006 10:14 PM

New Scripter On The Block :)
 
This is me being the guy who started learning scripting today.

function onCreated(){
e = "Penguin";
say(e);
}


function onCreated(){
e = "Penguin";
player.chat = e;
;


Now, the first would make me say penguin with anything I said correct? And the second would be only when I said e?

Admins 07-14-2006 11:04 PM

Would need to be say2 and it should not be in onCreated() I guess.
say2() displays a "sign", while assigning something to player.chat is changing the text over the player.
Instead of onCreated(), which is only called when the object is created, you should use onPlayerEnters() or similar.

killerogue 07-14-2006 11:06 PM

Ah thanks Stefan old boy. ;) Didn't your birthday just pass? :o I could be wrong.

Andy0687 07-14-2006 11:12 PM

Quote:

Originally Posted by killerogue
This is me being the guy who started learning scripting today.

function onCreated(){
e = "Penguin";
say(e);
}


function onCreated(){
e = "Penguin";
player.chat = e;
;


Now, the first would make me say penguin with anything I said correct? And the second would be only when I said e?

You are actually looking for onplayerchats for saying stuff anf getting stuff back.
NPC Code:

function onPlayerchats() {
}



That will start the whole ball rolling, now you want to return something when you say e?

NPC Code:

if (player.chat == "e") {
}



and return something else otherwise?

NPC Code:

else{
say2("e");
}



Now lets put it all into practice.

NPC Code:

function onPlayerchats() {
if (player.chat == "e") {
player.chat = "Penguin";
}else{
say2("Penguin");
}
}



Hope I have helped you some.

killerogue 07-14-2006 11:28 PM

I think I understand what you did. The way you scripted turned it into an action I'm guessing? By the if (player.chat == "e") this means if the player types the word e nd presses enter the player chat will turn into Penguin whereas using say2 it will be a box/sign?

Omini 07-15-2006 12:12 AM

Assuming you knew GS1

NPC Code:
if (playerchats) { }



is

PHP Code:

function onPlayerchats() {} 

and

NPC Code:
if (strequals(#c,chat)) { }



is

PHP Code:

if (player.chat == "chat") { } 

If that helps.

ApothiX 07-15-2006 08:59 AM

Quote:

Originally Posted by Omini
...

Considering he said he just learned scripting today, I think it's safe to assume he didn't know the old engine.

Novo 07-15-2006 10:59 AM

Quote:

Originally Posted by ApothiX
Considering he said he just learned scripting today, I think it's safe to assume he didn't know the old engine.

And nor shall he!

Twinny 07-16-2006 08:22 AM

PHP Code:

function onCreated() {
  
"Penguin";
}

function 
onPlayerchats() {
  if (
player.chat == "hello") {
    
message("I am a" SPC e);
  }


Now when a player says hello in the room with that NPC, it will reply "I am a Penguin".

ApothiX 07-17-2006 01:19 AM

Quote:

Originally Posted by Twinny
PHP Code:

function onCreated() {
  
"Penguin";
}

function 
onPlayerchats() {
  if (
player.chat == "hello") {
    
message("I am a" SPC e);
  }


Now when a player says hello in the room with that NPC, it will reply "I am a Penguin".

Would probably be better to use this.char (or just chat) instead of message to set the text. Also, you should avoid prefixless variables whenever possible, use this. or temp. instead.

PHP Code:

function onCreated() {
  
this.type "Penguin";
}

function 
onPlayerChats() {
  if(
player.chat == "hello") {
    
chat "I am a " this.type;
  }




All times are GMT +2. The time now is 07:40 AM.

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