Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 07-14-2006, 10:14 PM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
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?
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #2  
Old 07-14-2006, 11:04 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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.
Reply With Quote
  #3  
Old 07-14-2006, 11:06 PM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
Ah thanks Stefan old boy. Didn't your birthday just pass? :o I could be wrong.
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #4  
Old 07-14-2006, 11:12 PM
Andy0687 Andy0687 is offline
Enigma
Join Date: Feb 2002
Posts: 1,072
Andy0687 is on a distinguished road
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.
Reply With Quote
  #5  
Old 07-14-2006, 11:28 PM
killerogue killerogue is offline
Registered Omega
killerogue's Avatar
Join Date: Apr 2006
Location: United States
Posts: 1,920
killerogue is on a distinguished road
Send a message via AIM to killerogue Send a message via MSN to killerogue
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?
__________________


REMEMBER, IF YOU REP ME, LEAVE A NAME!

Quote:
Originally Posted by haunter View Post
Graal admins don't die. They go to hell and regroup.
Quote:
Originally Posted by Inverness View Post
Without scripters, your graphics and levels wouldn't do anything but sit there and look pretty.
Reply With Quote
  #6  
Old 07-15-2006, 12:12 AM
Omini Omini is offline
Millenium Owner
Join Date: Feb 2006
Location: N.Ireland
Posts: 293
Omini is on a distinguished road
Send a message via AIM to Omini Send a message via MSN to Omini Send a message via Yahoo to Omini
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.
__________________



Reply With Quote
  #7  
Old 07-15-2006, 08:59 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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.
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #8  
Old 07-15-2006, 10:59 AM
Novo Novo is offline
[TServerDeveloper]
Join Date: Jun 2006
Posts: 448
Novo will become famous soon enough
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!
Reply With Quote
  #9  
Old 07-16-2006, 08:22 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to 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".
Reply With Quote
  #10  
Old 07-17-2006, 01:19 AM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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;
  }

__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
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 08:17 PM.


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