Page 1 of 1

New to scripting?

Posted: 27 Sep 2011, 10:04
by meway
Scripting an NPC

Code: Select all

009-1.gat,81,41,0 script Milly 114, {
mes "[Milly]";
mes "\"Hello.\"";
close;
}
[/color]

Above is an example of an NPC saying Hello. This NPC is using multiple Messages. First it says [Milly] Than it says Hello.

1)

Code: Select all

009-1
is determining the map that the NPC is located.
Note: .Gat allows the server to recognize the map

Code: Select all

81,41
is the spot on the grid (using square unites) an NPC will stand while on a map. 1,1 being the very most upper left of the grid.

Code: Select all

,0 
Tells the NPC what way it is facing. This usually will remain 0

Code: Select all

script
is the command that indicates it is a script

Code: Select all

Milly
is the name printed in the client below the sprite (you will see this in game below the NPC sprite)

Code: Select all

114,
is the sprite id to be looked up in client data /npc.xml This file is located in your updates.

Code: Select all

{
indicates the start of a script
2)

Code: Select all

mes
This tells the client to print a message when you click on an npc.

Code: Select all

"
opens a place for you to type the printed message you want your npc to say

Code: Select all

"
At the end of the printed message, this lets the npc know the message is complete

Code: Select all

; 
This is placed after each command to indicate the command line is complete
3)

Code: Select all

mes
refer to number 2)

Code: Select all

"
starts a string

Code: Select all

\"
means there is a " within a string

Code: Select all

Hello.
Is the printed message

Code: Select all

\"
refer to 2 lines above

Code: Select all

"
refer to 2)

Code: Select all

;
refer to 2)
4)

Code: Select all

close 
is a command that allows a player the option to close the prompt while in game

Code: Select all

;
refer to 2)
5)

Code: Select all

}
indicates the end of the script
If I missed anything or you feel the need to edit this Paste-bin via pm and I will credit you for your alterations. I plan on continuing this thread with example npc and eventually creating 1 downloadable document

______________________________________________________________________
Authors: Meway, PjotrOrial

Re: New to scripting?

Posted: 27 Sep 2011, 11:12
by meway
I would add under Authors the person who created the milly script if I knew who that was.

Re: New to scripting?

Posted: 27 Sep 2011, 12:36
by Crush
Hi meway.

Thanks for writing this, but I think that the wiki would be a better place for this than the forum.

Re: New to scripting?

Posted: 27 Sep 2011, 12:51
by meway
If ali-g wants to work his magic I don't mind. But I dislike using the wiki myself so I will have to continue here.

Re: New to scripting?

Posted: 27 Sep 2011, 13:39
by Alige
I personally don't have the time to do this. I already need to do all the magic skills, all the NPCs and translate all that in french, moreover Wombat asked me to add few things on wiki a year ago, and I still didn't do that.

If people want to learn how to script, they just need to connect on IRC, ask some help and use their head.

Good job so far Meway, keep it up,
best regards,
Ali-G

Re: New to scripting?

Posted: 27 Sep 2011, 14:04
by meway