//---------------------------Miscellaneous Functions--------------------------

/**
 * Bunch of misc functions for all kind of options
*/

//This is basically bonus features and flavor text for a few of the more uncommon functions of a ghost. You don't HAVE to fill these out if you don't want to, the template's default dialogue will handle it (assuming you're making a two person ghost... if not, you may have to go through and remove Triangle's dialogue tags so he doesn't appear when you don't want him to). So if this file is boring or intimidating or you don't care, you can ignore it! These are again edge-cases compared to how often you'll see aitalk, bootend, or menu dialogue instead.

/*
This file has...

OnInstallBegin
OnInstallComplete
OnInstallFailure
OnInstallRefuse
OnVanishSelecting
OnVanishSelected
OnVanishCancel
OnVanishButtonHold
OnVanished
OnBIFFBegin
OnBIFFComplete
OnBIFFFailure
OnUpdateBegin
OnUpdateReady
OnUpdateComplete
OnUpdateFailure
OnUpdate.OnDownloadBegin
OnUpdate.OnMD5CompareBegin
OnUpdate.OnMD5CompareComplete
OnUpdate.OnMD5CompareFailure
OnHeadlinesenseBegin
OnHeadlinesense.OnFind
Select.Headline_Cancel
OnHeadlinesenseComplete
OnHeadlinesenseFailure
OnUpdatedataCreating
OnUpdatedataCreated
OnNarCreating
OnNarCreated
OnSNTPBegin
OnSNTPCompare
OnSNTPEXECUTE
OnSNTPCANCEL
OnSNTPFailure
OnDisplayChange
OnScreenSaverStart
OnScreenSaverEnd
OnApplicationBoot
OnApplicationClose
OnApplicationFileOpen
OnBatteryLow
OnBatteryCritical
OnShellScaling
OnFileDrop2
*/

// Don't let this be a roadblock for you! It's basically bonus material! What matters is your aitalk file more than anything. You can always come back to this and fill it out over time once your ghost is already published. Don't get stuck here! I know it's easy to do so but don't let it happen to you! If you're getting stuck here just walk out, you can leave! lol. There's always aitalk, bootend, and menu to have more fun with, and that's the dialogue your user is going to see the most often.

/**
 * OnInstallBegin is called when a file with an included install.txt is dropped, either .nar containing another ghost or .zip containing baloon or shell
*/
OnInstallBegin
 {
	"\0\s[0]Установочный файл? Интересно, что внутри..\e"
 }

/**
 * OnInstallComplete runs once the file above has finished installing.
 * reference0 - string with archive type. Can be "shell", "ghost", "balloon", "plugin", "calendar skin", "headline", or "rss".
 * reference1 - string shell/ghost name as defined in descript.txt 
*/
OnInstallComplete
 {
	"\0" //this means sakura will be speaking first, therefore the \s[] at the beginning of each line will be defining sakura pose.
 	--
	if reference0 == "shell"
 	{	
		if reference1 == "Mockup Shell" 
		{
		"\s[0]Does it really exists?\e" // a mockup
		}
		else
		{
		"\s[0]Хмм.. все проверки пройдены, целостность архива подтверждена, шелл %(reference1) установлен, %(username).\e"
		}
 	}
	elseif reference0 == "ghost" 
 	{
		"\s[0]Все проверки пройдены, целостность архива подтверждена, поздоровайся с %(reference1), %(username). Ты тоже не стисняйся, %(reference1), скажи 'привет'!\e"
 	}
	elseif reference0 == "balloon" 
 	{
		"\s[0]Новый баббл - '%(reference1)' - успешно установлен. Опробуем его?\e"
 	}
	elseif reference0 == "plugin" 
 	{
		"\s[0]Закончила, плагин '%(reference1)' успешно установлен. А что он делает?\e"
 	}
	elseif reference0 == "calendar skin" 
	{
		"\s[0]Та-даа! Новый дизайн календаря - '%(reference1)'. Если бы у Люмы была стена, она бы повесила новый календарь на стену, чтобы смотреть на него каждый день~"
	}
	elseif reference0 == "headline" 
	{
		"\s[0]Все проверки пройдены, целостность файла подтверждена, хэдлайн '%(reference1)' успешно добавлен.\e"
	}
	elseif reference0 == "rss" 
	{
		"\0\s[0]Новая RSS лента '%(reference1)' успешно добавлена! Теперь Люме будет не так скучно, когда она остаётся одна. Посмотрим, что там нового?\e"
	}
	else 
	{
		"\s[0]Installed %(reference1)."
	}
}

/**
 * If the file user dropped fails to install for one reason or another.
 * reference0 - reason for the error, e.g. "unsupported" or "extraction"
*/
OnInstallFailure
 {
	"\0\s[0]Ой, установка сорвалась..\n\n[half]\w5" 
	--
	if reference0 == "unsupported" 
	{
	"Кажется, SSP не поддерживает этот вид файлов..\e"
	}	
	elseif reference0 == "extraction" 
	{
	"Что-то не так с архивом - не получается его распаковать.\e"
	}
 }
 
/**
 * If the file user dropped can't be installed with this ghost.
 * reference0 - name of the ghost this resource is intended for, as listed in install.txt file. e.g. shell, dropped on Lyuma, that belongs to some other ghost.
*/
OnInstallRefuse
 {
	"\0\s[0]Люма не может это использовать. \w4Может, %(reference0) знает что с делать с этим файлом?\e"
 }

//--OnVanishSelecting
/**
* Initiate uninstallation
*/

OnVanishSelecting
 {
	"\0\s[0]Эта опция сотрёт Люму из твоей системы, %(username).\e"
 }

//OnVanishSelected
/**
 * Uninstallation confirmed
*/
OnVanishSelected
 {
	"\0\s[0]Пока-пока, спасибо за всё время вместе\w9\w9\e"
 }

/**
 * Uninstallation cancelled
*/
OnVanishCancel
 {
	"\0\s[0]Не будешь удалять? Люма рада, что ей можно пожить ещё\e"
 }

/**
 * This should trigger if the user double clicks the ghost's balloon in the middle of OnVanishSelected above, effectively cancelling their uninstallation.
 * Wierd scenario I don't paricluarily intend to comment. 
*/
OnVanishButtonHold
 {
	//"\1\s[10]This dialogue displays when the user double clicks on the balloon when we're saying we're going to uninstall ourselves.\e"
 }

/**
 * If the user uninstalls a ghost, it'll automatically go back to the last ghost you were using.
 * The ghost appeared will say this line of dialogue about the ghost you just uninstalled.
 * reference0 - name of the deleted ghost
*/
OnVanished
 {
	"\0\s[0]Пока, %(reference0).\e"
 }


//**** Mail Checking *******************************************************************
//The next set of functions have to do with checking your email. This function is a slippery little thing - I've had people test it following my directions and have it work, but I've never actually gotten it to report back the right amount of emails myself. Very frustrating. But perhaps you'll have more luck with it, haha.
//Girl and Triangle can't actually read your email, they can just tell you how many emails you have. I've seen ghosts that can read the HEADERS of email, but I still don't think ghosts can actually display the contents of an email. You should be using your actual email client for that. It's still kind of a neat feature though.

/**
 * When you first tell the ghost to check your email. An intro statement, if you will.
 * reference2 - name of the server being checked
*/
OnBIFFBegin
 {
	"\0\s[0]Ага, предоставь это Люме.\e"

	"\0\s[0]Почта? Сейчас проверю.\e"

	"\0\s[0]\f[name,Hymmnos,hymmnos.ttf]\f[height,16]j.w. mea ADDR => \f[default]\n\n%(reference2)\e"
 }

/**
 * Email number successfully retieved.
 * reference0 - number of emails
 * reference2 - name of the server being checked
 * reference7 - the senders and titles delimited by C_BYTE1 characters
 * see: https://ukagakadreamteam.github.io/ukadoc/manual/list_shiori_event.html
*/
OnBIFFComplete
 {
	if reference0 == 0 
 	{
 		"\0\s[0]%(username), в ящике пусто. Наверное лучше проверить позже.\e"

 		"\0\s[0]Ничего нового.\e"
	}
	elseif reference0 > 0 && reference0 < 13 
	{
		"\0\s[0]Ответ от сервера получен, пришло %(reference0) новых писем. Посмотрим?\n\n\![set,autoscroll,disable]\_q"

		"\0\s[0]Передача данных завершена. На сервере %(reference0) новых писем.\n\n\![set,autoscroll,disable]\_q"

		"\0\s[0]Письма из Хогвартса там всё ещё нет, но есть %(reference0) новых писем. Сейчас зачитаю...\n\n\![set,autoscroll,disable]\_q"
		--
		{
			OnPrintMailAsList(reference7)
		}
		--
		"\e"
	}
	elseif reference0 > 12 && reference0 < 100 
	{
		"\0\s[0]%(reference0) новых писем, довольно много. Давай не будем читать каждое.\e"
	}
	elseif reference0 > 99 
	{
		"\0\s[0]%(reference0) новых писем? %(username), давно ты в последний раз проверял свой почтовый ящик?\e"

		"\0\s[0]%(reference0) новых писем. Наверное, тебе всё таки стоит начать их читать.\e"
	}
 	else 
	{
		"\0\s[0]Пришло %(reference0) новых писем, %(username).\e"
 	}
 }

/**
 * Function that prints a string of email senders and titles as unordered list
 * _argv[0] - a string of entries in format "SenderName <Sender@email.eg> Message title" separated by C_BYTE1 chars
 * returns formatted headers as list
 * : last modifier will ensure only last return candidate gets returned
*/
OnPrintMailAsList : last
 {
	_headers = SPLIT(_argv[0],"")
	_letters = ""
	_headerRegex = "\s*(\S+)\s*<([^>]+)>\s(.*)" // Name <email@example.com> Message title

	foreach _headers; _header
	{
		if RE_MATCH(_header,_headerRegex) > 0 
		{
			_letterTitle = SHIORI3FW.EscapeAllTags(RE_GETSTR[3])
			if RE_GETSTR[3] == ""
			{
				_letterTitle = "<не указано>"
			}
			_letters += "От: %(RE_GETSTR[1]) \nАдрес: %(RE_GETSTR[2]) \nТема: %(_letterTitle)\n\n"
		}
	}

	_letters // returning formatted string
 }

//Various error messages that can happen when your ghost tries to connect to an email account. Replace the dialogue as appropriate.
OnBIFFFailure
 {
	if reference0 == "timeout" //If the connection times out.
 	{
 		"\0\s[0]The connection has timed out.\e"
	}
 	elseif reference0 == "kick" //If the account blocks the ghost from accessing it. I think gmail may do this at first to try and protect your account from unapproved applications using it. It gives you the option to change the setting in the warning email they send you about it.
	{
		"\0\s[0]We can't access the account.\e"
 	}
	elseif reference0 == "defect" //If the information put into the POP menu is wrong.
 	{
 		"\0\s[0]The email account was not set up properly.\w8\1\s[10]It can be reset at the POP menu.\w8\![open,configurationdialog]\e"
		
		//Note that this ends with \![open,configurationdialog]. This will open up the preferences menu I described above automatically. More on \! functions in the walkthrough. You can delete the \! tag here if you want to.
	}
 	else //if there's some other kind of error.
	{
		"\0\s[0]We can't connect to the account.\w8\1\s[10]The error returned is '%(reference[0])'.\e"
		
		//reference0 here stores the error message the email server would have given the ghost, hopefully.
 	}
 }


 //**** Network Update *****************************************************************
 //The following functions are for the Network Update of your ghost, where it will connect to your website, check for new files, and update itself. This is a handy feature, but tricky to set up. If you have no intention of using Network Update, you can disregard these, but it won't hurt to fill them out anyway just in case. More details about how to set up Network Update are in the walkthrough (http://www.ashido.com/ukagaka/).
 
 //Replace the dialogue in the next set of functions as appropriate. You can easily test these messages using the Developer panel. Go to Open at the bottom of it and choose one of the four Update Event options to simulate a Ghost's update process. I highly recommend doing this at LEAST once if you're going to use this feature to make sure it flows well.

 
 //---- OnUpdateBegin -------------------------------------------------------------
 //When you first tell your ghost to update. An introductory statement, like OnBIFFBegin above. Replace or add more dialogue as appropriate. Note that they end with \w8 to give a little breather time.
 
OnUpdateBegin
 {
	"\0\s[0]Starting the update process.\w8\e"
	
	"\1\s[10]Another message for starting the update process.\w8\0\s[0]Hope you read the directions properly.\w8\e"
 }

 //---- OnUpdateReady ---------------------------------------------------------
 //If the ghost finds new files to update with.
 
OnUpdateReady
 {
 
	reference0++ //makes sure it starts at 1 instead of 0
	
    "\1\s[10]There are %(reference0) new files.\w8\e"
	
	//reference0 here storing the number of new files. You don't have to use it if you don't want to.
 }


//---- OnUpdateComplete -------------------------------------------------------------
//When the ghost has finished the update process.

OnUpdateComplete
 {
	if reference0 == "none" //if the ghost had nothing to update with
 	{
 		"\1\s[10]There are no new files.\e"
		
		"\1\s[10]This is another message about there being no new files to update with.\e"
	}
 	else //if the ghost has updated successfully
	{
		"\1\s[10]Update successful!\e"
 	}
 }

 //---- OnUpdateFailure -------------------------------------------------------------
 //Error messages if the update process fails in some way.
 
OnUpdateFailure
 {
	 _file = SPLITPATH(reference1)[2] + SPLITPATH(reference1)[3] //This gets the name and extension of the offending file
	 
	 
	if reference0 == "timeout" //if the connection times out
 	{
 		"\1\s[10]The update connection has timed out.\e"
	}
 	elseif reference0 == "md5 miss" //This is the final message displayed when you've run into an md5 error below at some point.
	{
		"\1\s[10]The MD5 hash of %(_file) doesn't match.\e"
 	}
	else //for other errors
 	{
 		"\1\s[10]The update could not be completed.\w8\0\s[0]The error is '%(reference0)'.\e"
	}
 }


 //---- OnUpdate.OnDownloadBegin ------------------------------------------------
 //This dialogue plays when they begin downloading a new file. WARNING: if you have big plans for your ghost and are going to make a lot of new image files for it (like... i do, cough) at some point, you're going to want to make these messages very brief, if you even have them at all. The reason is because the user will see these messages for EVERY individual file that they have to download, and if you have, say, 50 pna files in the queue, they will see this dialogue 50 times. Not only that, but displaying the dialogue takes some time, so it also extends the download process.
 //If you aren't planning on adding a ton of files at any point, or are only intending to update the .dic files which will be at most a handful of files, then you can go ahead and put a short message in here. But if your ghost is going to grow in leaps and bounds as you work on it, try and keep these messages as brief as possible (or again, just make it "" to have there be no message at all) to make the process that much faster for your user.
 
OnUpdate.OnDownloadBegin
 {
 	if "aitalk" _in_ reference0 //this is checking to see what kind of files are being downloaded. In this case, it's looking for files called aitalk in the download queue. If you want to have a specialized bit of dialogue for each type of file, you can expand this with elseifs and by replacing aitalk with whatever file you have in mind. Keep in mind my warning above though.
 	{
 		"\0\s[0]We are going to download more dialogue.\w8\1\s[10]It's in the aitalk file.\e"
 	}
 	else //for files not specified above
 	{
	"\1\s[10]This is dialogue for finding a new file.\e"
	
	"\0\s[0]This is another bit of dialogue for finding a new file.\e"
	}
 }

 //---- OnUpdate.OnMD5CompareBegin ---------------------------------------------------
 //This checks the hash value of the files in the directory and the files listed in updates.dau, I believe. It will do this for every file the user downloads, so I again remind you of my warning above! For every file they download, they will have to go through three sets of unique dialogue, and it can get old fast. Not to mention it slows things down a lot. Again, I would recommend keeping this very brief, if not just replacing it with "" instead.
 
OnUpdate.OnMD5CompareBegin
 {
	"\1\s[10]Checking the MD5 value.\e"
 }

 //---- OnUpdate.OnMD5CompareComplete --------------------------------------------------
 //After they've checked the MD5 value and it matches. See above about the length of this message.
 
OnUpdate.OnMD5CompareComplete
 {
	"\0\s[0]MD5 check good.\e"
}

 //---- OnUpdate.OnMD5CompareFailure ---------------------------------------------------
 //If the MD5 values don't match, meaning if the file is missing or damaged or incomplete in some way. If you follow my Network Update directions carefully, this shouldn't come up very often, but don't be surprised if you run into it every now and then by forgetting a file here or there.
 
OnUpdate.OnMD5CompareFailure
 {
	"\0\s[0]The MD5 values don't match.\w8\e"
 }

 
 
 //**** Headlines and RSS Feeds *********************************************************
 //This section has to do with the RSS feeds option on your ghost. If you drag and drop a url on them, they'll add it to a list you can access via the right-click menu, and they'll tell you the last set of updates for the site. This works best with RSS feeds I think, but you can experiment with other sites to see how it works.
 //The headlines you see under the tab are in the headline folder under your base SSP install. So it'd be SSP\headlines. You should see the folders for each linked headline in there. I've very rarely ever messed with them or used them. Likewise, your RSS feeds you've added will be under SSP\rss and I don't think that option will appear in the headlines/RSS tab until you add an RSS feed to a ghost. If you want to clear your RSS feeds or headlines, just delete either of those two folders.
 

 //---- OnHeadlinesenseBegin -----------------------------------------------------------
 //This dialogue comes up when you select something in your RSS feed as an intro, like the other On[Thing]Begin things we've seen so far. Replace as you need.
 
OnHeadlinesenseBegin
 {
	"\0\s[0]You've selected %(reference0).\e"
 }

 //---- OnHeadlinesense.OnFind --------------------------------------------------------
 //This actually displays the feed. My set-up for it is pretty simple but gets the job done, it just has the name of the feed, a line space, then a list of links. You shouldn't have to edit any of these and I probably wouldn't honestly.
 
OnHeadlinesense.OnFind
{
	//----  What page You're on
 	if reference2 == "First" || reference2 == "First and Last"
	{
 		//---- First page
		"\0\b2\s[0]%(reference0):"
 	}
	elseif reference2 == "Next"
 	{
		//---- Second page
 		"\0\b2\s[0]%(reference0):"
	}
 	elseif reference2 == "Last"
	{
 		//---- Last page
		"\0\b2\s[0]%(reference0):"
 	}
	--
 	//---- Headlines
	"\n\n%reference3\n"
 	--
	//---- Pages
 	if reference2 == "First" || reference2 == "Next"
	{
 		//---- Bottom buttons
		"\![*]\q[Next,] - \![*]\q[Stop,Headline_Cancel]\e"
 	}
	else
 	{
		//---- Bottom buttons
 		"\![*]\q[Stop,Headline_Cancel]\e"
 	}
	
}


Select.Headline_Cancel
{
	"\0\s[0]Headline viewing complete.\e"
	//Actually I take that back, you can change this line of dialogue here for when you're done looking at a headline to something else if you want.
}

 //---- OnHeadlinesenseComplete -------------------------------------------------------
 //This is an odd function. As far as I can gather, this is if the headline information gathering was successful, but there's no new information to report. Possibly if none of the feeds have updated? I'm a little fuzzy on this one.
 
OnHeadlinesenseComplete
 {
	"\0\s[0]No update. %(reference0).\e"
	//reference0 here supposedly always stores the value no update? Again this isn't hugely clear from what I can see. Anyway, this dialogue has never come up for me while using a ghost, so perhaps someone else who runs into it can offer more clarity. For now, you can leave it as is, or write up something else in here if you like.
 }

 //---- OnHeadlinesenseFailure ---------------------------------------------------------
 //This one is more clearly for when the ghost can't get the information it needs about the RSS feed in question.
 
OnHeadlinesenseFailure
  {
	"\0\s[0]The feed can't updated.\w8\1\s[10]Why not?\w8\0\s[0]\n\n[half]" //This sets up an exchange between the two characters. The final part of the exchange continues below in the if statements.
 	--
	if reference0 == "can't download" //if they can't download the rss feed for some reason
 	{
		"It can't be downloaded."
 	}
	elseif reference0 == "can't analyze" //if they can't read the file for some reason
 	{
		"It can't be analyzed."
 	}
	else //other errors
 	{
		"I don't know."
 	}
	--
 	"\e" //And here is the final /e, so you don't need to include it in the if statements above. Another one of the very rare cases this occurs.
}


//**** Ghost Creation and Updating ******************************************************
//These next few are related to creating updates2.dau and .nar files for your ghosts. You'll want to at least make a .nar to distribute your ghost, and if you're going to be using Network Update, you'll also want to make updates2.dau as well. It's unlikely that anyone other than you will see these messages, but they can be fun to add some color to while you're developing. I gave Temmie some silly ones and they make me smile each time I update her.
//Primarily, you will see these messages when you're creating your updates file or updating your ghost.nar file. More on this on the walkthrough page. However, you can drag and drop another ghost's folder onto them and they'll also create a nar for that as well, if for some reason you want to do that.


 //---- OnUpdatedataCreating -----------------------------------------------------------
 //This will begin the creation of the updates2.dau file. Not unlike the other beginning functions you've seen throughout this file. Replace with whatever you like.
 
OnUpdatedataCreating
 {
	"\1\s[10]Creating the updates2.dau file.\e"
 }

 //---- OnUpdatedataCreated -------------------------------------------------------------
 //After the updates2.dau file has been successfully created. Replace with whatever.
 
OnUpdatedataCreated
 {
	"\0\s[0]Successfully created updates2.dau.\e"
 }

 //---- OnNarCreating ------------------------------------------------------------------
 //Along the same lines, this is when they begin creating a .nar file for your ghost. .nars are the format most ghosts will be in, something similar to a .zip file, and this is the format you'll be distributing your ghost in most likely. Replace the dialogue with whatever you like.
 
OnNarCreating
 {
	"\0\s[0]Creating the .nar file.\e"
 }

 //---- OnNarCreated -------------------------------------------------------------------
 //After the nar file has been successfully created.
 
OnNarCreated
 {
	"\0\s[0]Successfully created '%(reference0)'.\e"
	//reference0 here will be the filename of the nar you just created. It should drop the nar in the folder where all your ghosts are listed, ssp\ghost\.
 }

 //****　Clock Synchronization　**********************************************************
//**** 미카 (http://homepage2.nifty.com/ko-ki/)의 사전을 참고했습니다．감사＞こ 나무 성
//This set of functions was done by the above Korean coder, I think. I'll leave their comment there untouched. 
//If you right click your ghost and go into the Utilities menu, there's an option called NTP Time Sync. That's what this is for!
 

 //----OnSNTPBegin ------------------------------------------------------------------
 //As with the others you've seen above, this is the beginning bit of dialogue for this process.
 
OnSNTPBegin
 {
	"\0\s[0]We're going to check the time.\w9\1\s[10]We are connecting to %(reference0).\e"
	//%(reference0) here is the site they'll be using to check your clock. I wouldn't worry too much about what the site is or where it's defined, it should be accurate. Replace the dialogue with what you need, you don't have to use reference0 if you don't want to.
 }


 //----　OnSNTPCompare----------------------------------------------------------
 //Now the ghost is going to compare the current time of your computer's system to the time of the site they connected to. Most of this you don't have to touch, just replace the dialogue as indicated.
 
OnSNTPCompare
 {
 	"Retrieved Time: %reference1[1]/%reference1[2]/%reference1[0] %reference1[3]:%reference1[4]:%reference1[5]\w2\n/
	Your Time: %reference2[1]/%reference2[2]/%reference2[0] %reference2[3]:%reference2[4]:%reference2[5]\w2\n/
 	\n"
	--
 	if reference3 == 0 //if your clock is already accurate.
	{
 		"\0\s[0]Your clock is accurate.\e" //replace this with whatever message you like.
	}
 	else //if your clock doesn't match
	{
	//you can redo this top line up to the \n\n[half] part, but leave the \q options alone.
 		"\0\s[0]Your clock doesn't match.\w6\nShould we fix it?\n\n[half]/
		\![*]\q[Fix it,OnSNTPEXECUTE]\n/
 		\![*]\q[Leave it alone,OnSNTPCANCEL]\e"
	}
 }

 //----　OnSNTPEXECUTE ------------------------------------------------------------------
 //After they've fixed your clock. Note the \6 tag - that's what actually changes the clock. Do not remove that tag. Replace the rest with what you want.
 
OnSNTPEXECUTE
 {
	"\0\s[0]The clock has been fixed.\6\e"
 }

 //----　OnSNTPCANCEL ------------------------------------------------------------------
 //If you decide not to change your clock when they tell you it doesn't match. Replace with what you want.
 
OnSNTPCANCEL
 {
	"\0\s[0]The user decided not to change the clock.\e"
 }

 //----　OnSNTPFailure ------------------------------------------------------------------
 //If they can't change the clock for some reason, possibly because the site timed out but it could be anything. Replace with what you want.
 
OnSNTPFailure
 {
	"\0\s[0]The clock wasn't changed.\w8\1\s[10]Something went wrong.\e"
 }


 //--OnDisplayChange----------------------------------------------------------------
 //This is when you change the resolution of your monitor while your ghost is running. Don't mess with any of this, it should be fine as is.
 
OnDisplayChange
 {
	displaybpp    = reference0
 	displaywidth  = reference1
	displayheight = reference2
 }



 //---- OnScreenSaverStart -------------------------------------------------------
 //This happens if your ghost is running when your screensaver starts up. I've never got this to trigger but I love this idea, and I feel like there's a way to do it I haven't figured out yet. So you can skip these for now if you want, but if I do ever get it working, I'll come back and make a note of it.
 
OnScreenSaverStart
 {
	"\0\s[0]The screensaver is starting.\w7\1\s[10]Wiggle your mouse!\e"
	//Replace with what you want.
 }

 //---- OnScreenSaverEnd -------------------------------------------------------
 //When you wiggle your mouse and stop your screensaver.
 
OnScreenSaverEnd
 {
	"\0\s[0]The screensaver is gone.\e"
	//Replace with what you want.
 }


 //---- OnApplicationBoot ---------------------------------------------------------------
 //This supposedly is for when a program starts but I have honestly never gotten it to work or seen it happen. I wouldn't sweat these three related functions too much.
 
OnApplicationBoot
 {
	"\0\s[0]%(reference0) just started.\e"
 }

 //---- OnApplicationClose --------------------------------------------------------------
 //See above, but for the program closing.
 
OnApplicationClose
 {
	"\0\s[0]%(reference0) has closed.\e"
 }

 //---- OnApplicationFileOpen ----------------------------------------------------------
 //I believe this is for when the program detailed above opens a document file of some kind.
 
OnApplicationFileOpen
 {
	"\0\s[0]Opening %(reference1).\e"
 }




 //---- OnBatteryLow -----------------------------------------------------------------
 //This is for when your laptop's battery is low. I don't have a laptop, so I've never really been able to test this. Perhaps someone with a laptop can report back to me with more details about the battery related functions?
 
OnBatteryLow
 {
	"\1\s[10]The laptop's battery is low. \w8\0\s[0]There is %(reference0) power left.\e"
	//reference0 here is the amount of battery power. Replace as you like.
 }
 
 //--OnBatteryCritical-----------------------------------------------------------------
 //Likewise, this is for if your battery is REALLY low. Replace as you like.
 
OnBatteryCritical
{
	"\0\s[0]The laptop's battery is critically low.\e"
}
 
//--OnBatteryNotify--------------------------------------------------------------------
//This I believe checks to see if your laptop is plugged in or not. Originally this bit of code was commented out, so I suspect it may not work. It may need a plug-in of some sort. Either way, you can delete it or fill it out as you like.
//Actually investigating this, leaving this in makes it so the ghost updates you about whether or not your computer is plugged-in constantly, which makes no sense for desktops. No doubt why it was commented out. You can delete it or just leave it be.

/*
OnBatteryNotify
{
	if reference2 == "online" //If your laptop is plugged in
	{
		"\0\s[0]The laptop is plugged in.\e"
	}
	elseif reference2 == "offline" //If you unplug your laptop
	{
		"\1\s[10]The laptop is not plugged in.\w8\0\s[0]Watch your battery.\e"
	}
}
*/


 //--OnShellScaling
 //This is a function however that you may actually use! Or at least, I often use it when desktop space is at a premium (which it always is on my computer). If you right click the ghost, you can go to Shell Scaling, which lists a number of different percentages. Those are the percentages your ghost can be scaled in size up or down. You can try them out yourself to get an idea of what I mean. I often scale mine down to get them out of the way sometimes. This adds dialogue whenever you change their scale. You don't have to do this if you don't want to, in which case they will just stay silent when you size them up or down. If that's what you want, just delete the whole thing or leave "" instead of any dialogue.
 
OnShellScaling
{
	if reference0 >= 150 //this number is the percentage that you're scaling the ghost up to. In this case, it's 150%.
	{
		"\0\s[0]We are now 150% our original size.\w8\1\s[10]Bigger.\e"
	}
	elseif reference0 == 100 //this is 100%
	{
		"\1\s[10]We are normal sized.\e"
	}
	elseif reference0 == 50 //this is 50%. You can add any percentage that's listed under shell scaling if you want using more elseifs.
	{
		"\0\s[0]We are now 50% our original size.\w8\1\s[10]Smaller.\e"
	}
}


//--OnFileDrop2

//OnFileDrop2 handles how your ghost will set an image as the desktop background when someone drags and drops an image on them. You don't need to touch any of the coding here, just replace the dialogue as needed and leave the \q options alone. More about \q options in bootend.dic and in the walkthrough.

OnFileDrop2
{
	_filepath = SPLITPATH(reference0)
	_filename = _filepath[2]
	_fileext = TOLOWER(_filepath[3])
	case _fileext
	{
		when ".jpg", ".jpeg", ".bmp", ".png" //These are the formats your ghost will recognize as image files to set as the background.
		{
			Wallpaperfile = reference0
			
			"\0\s[0]The file you dropped is %(_filename)%(_fileext).\w8\1\s[10]How would you like us to set this picture as your wallpaper?\n\n[half]/
			\![*]\q[Centered,SetWallpaper_0]\n/
			\![*]\q[Tiled,SetWallpaper_1]\n/
			\![*]\q[Stretched,SetWallpaper_2]\n\n[half]/
			\![*]\q[No thanks,SetWallpaper_Cancel]\e"
		}
		when ".mid", ".wav", ".mp3", ".wma", ".au" //Other file formats you might want to give your ghost a specific response to.
		{
			"\1\s[10]%(_filename)%(_fileext) is a music file.\e"
		}
		others //Any other file format. As a note here, if you drop something ghost-related on them that does not have an install.txt, then they won't install it and will just say this response. If you are testing your balloon or nar files and you get this response instead of a proper installation, you should check and make sure you have an install.txt in the file!
		{
			"\0\s[0]This is %(_filename)%(_fileext).\e"
		}
	}
}

//This set of options sets the wallpaper up. You can replace the dialogue, but make sure to leave the \![set,wallpaper, etc.] tag at the beginning.

Select.SetWallpaper_0
{
	"\![set,wallpaper,%(Wallpaperfile),center]\0\s[0]The image is centered.\e"
}
Select.SetWallpaper_1
{
	"\![set,wallpaper,%(Wallpaperfile),tile]\0\s[0]The image is tiled.\e"
}
Select.SetWallpaper_2
{
	"\![set,wallpaper,%(Wallpaperfile),stretch]\0\s[0]The image is stretched.\e"
}
Select.SetWallpaper_Cancel
{
	"\0\s[0]You don't want to set the file as your desktop background.\1\s[10]Kay.\e"
}