PDA

View Full Version : New Scripter On The Block :)


killerogue
07-14-2006, 11:14 PM
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-15-2006, 12:04 AM
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-15-2006, 12:06 AM
Ah thanks Stefan old boy. ;) Didn't your birthday just pass? :o I could be wrong.

Andy0687
07-15-2006, 12:12 AM
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.

function onPlayerchats() {
}


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


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


and return something else otherwise?


else{
say2("e");
}


Now lets put it all into practice.


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


Hope I have helped you some.

killerogue
07-15-2006, 12:28 AM
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, 01:12 AM
Assuming you knew GS1

if (playerchats) { }

is

function onPlayerchats() {}

and

if (strequals(#c,chat)) { }

is

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

If that helps.

ApothiX
07-15-2006, 09:59 AM
...

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, 11:59 AM
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, 09:22 AM
function onCreated() {
e = "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, 02:19 AM
function onCreated() {
e = "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.

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

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