Title: Ex #1: Basic Event Hooks Example Post by: pspeed on January 09, 2012, 10:13:10 AM So, I'm going to create a few sticky topics with some scripting basics for those who are interested. This is easier than creating wiki pages at the moment but they will eventually migrate there. Once that happens then I will unsticky these and add a new "see the wiki" sticky topic.
For the first example script, I show the basics of hooking a script into one of the many events provided by the game. In this case "playerJoined" which is the most common script hook. In single player, you can create a mods/scripts directory underneath where you run Mythruna. Copy this script in and it will run whenever you start a single player game. On a server, this script would go in the scripts sub-directory under where you run the server. Comments hopefully explain what is happening. Code:
That script will print a simple welcome message to the player when they join and will add a "hello" command to their in-game console. Next up will be adding a custom tool to a player... but this one was the foundation for that one. Title: Re: Ex #1: Basic Event Hooks Example Post by: Rayblon on September 07, 2015, 02:10:07 AM Since I'm clogging the wiki with junk right now, should I add this to the list or leave it to you?
Title: Re: Ex #1: Basic Event Hooks Example Post by: pspeed on September 07, 2015, 05:24:25 PM Since I'm clogging the wiki with junk right now, should I add this to the list or leave it to you? I don't know. I don't plan to do anything with the wiki any time soon. I don't know if that's an answer, though. Title: Re: Ex #1: Basic Event Hooks Example Post by: Michael on September 07, 2015, 06:12:23 PM Since I'm clogging the wiki with junk right now, should I add this to the list or leave it to you? Go ahead. Let the force be with you.Title: Re: Ex #1: Basic Event Hooks Example Post by: Rayblon on September 07, 2015, 06:18:36 PM I'll just... put these in a scripting help page, I guess. With copy+paste. Because that's professional.
Title: Re: Ex #1: Basic Event Hooks Example Post by: Rayblon on September 07, 2015, 07:15:55 PM So, I can do it, but... The wiki won't recognize a line as code if it doesn't have a space at the beginning. I don't know if that affects anything or not.
EDIT: I get it now, it eats a space on every line. If I add a space on each line, the code should be unaffected. Title: Re: Ex #1: Basic Event Hooks Example Post by: Rayblon on September 07, 2015, 07:37:54 PM It was a pretty clean transplant when I got it all formatted right. I even worked in a scrolling textbox for the code :D (http://mythruna.com/mediawiki/index.php?title=Scripting_Help)
Title: Re: Ex #1: Basic Event Hooks Example Post by: Michael on September 30, 2015, 07:39:33 PM It was a pretty clean transplant when I got it all formatted right. I even worked in a scrolling textbox for the code :D (http://mythruna.com/mediawiki/index.php?title=Scripting_Help) By the way, I already had a Scripting and Modding category:http://mythruna.com/mediawiki/index.php?title=Mythruna_Wiki:Community_portal Title: Re: Ex #1: Basic Event Hooks Example Post by: Rayblon on September 30, 2015, 08:37:39 PM It was a pretty clean transplant when I got it all formatted right. I even worked in a scrolling textbox for the code :D (http://mythruna.com/mediawiki/index.php?title=Scripting_Help) By the way, I already had a Scripting and Modding category:http://mythruna.com/mediawiki/index.php?title=Mythruna_Wiki:Community_portal I was just moving information over so yeh. If you want, you could always move the stuff elsewhere and create a redirect page. |