New to scripting?

Content and general development discussion, including maps, quests, and server code from the development team.
Post Reply
User avatar
meway
Knight
Knight
Posts: 1736
Joined: Sun Jan 04, 2009 6:02 am
Location: Detroit MI
Contact:

New to scripting?

Post by meway » Tue Sep 27, 2011 11:04 am

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
Attachments
screen.png
screen.png (231.62 KiB) Viewed 784 times
Last edited by meway on Tue Sep 27, 2011 12:13 pm, edited 1 time in total.
User avatar
meway
Knight
Knight
Posts: 1736
Joined: Sun Jan 04, 2009 6:02 am
Location: Detroit MI
Contact:

Re: New to scripting?

Post by meway » Tue Sep 27, 2011 12:12 pm

I would add under Authors the person who created the milly script if I knew who that was.
User avatar
Crush
TMW Adviser
TMW Adviser
Posts: 8046
Joined: Thu Aug 25, 2005 5:08 pm
Location: Germany

Re: New to scripting?

Post by Crush » Tue Sep 27, 2011 1:36 pm

Hi meway.

Thanks for writing this, but I think that the wiki would be a better place for this than the forum.
  • former Manasource Programmer
  • former TMW Pixel artist
  • NOT a game master

Please do not send me any inquiries regarding player accounts on TMW.


You might have heard a certain rumor about me. This rumor is completely false. You might also have heard the other rumor about me. This rumor is 100% accurate.
User avatar
meway
Knight
Knight
Posts: 1736
Joined: Sun Jan 04, 2009 6:02 am
Location: Detroit MI
Contact:

Re: New to scripting?

Post by meway » Tue Sep 27, 2011 1:51 pm

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.
User avatar
Alige
Developer
Developer
Posts: 1398
Joined: Sat Jan 09, 2010 8:22 pm
Location: Weed Island

Re: New to scripting?

Post by Alige » Tue Sep 27, 2011 2:39 pm

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
Image
User avatar
meway
Knight
Knight
Posts: 1736
Joined: Sun Jan 04, 2009 6:02 am
Location: Detroit MI
Contact:

Re: New to scripting?

Post by meway » Tue Sep 27, 2011 3:04 pm

Post Reply