#CLASS {PortalRep}
#SA {Kernighan's Portal Script V1.2}
;// ********************************************
;// ********************************************
;// **                                        **
;// ** The following 2 triggers will have to  **
;// ** be edited to match your command prompt **
;// **                                        **
;// ********************************************
;// ********************************************

#TRIGGER {(%n)hp (%n)m (%n)mv *} {#var {MountP} {0}}
#TRIGGER {(%n)hp (%n)m (%n)MountMV *} {#VAR {MountP} {1}}

;// Set Mount
#VAR {Mount} {Appaloosa}

;// MountP uses your prompt to determine whether or not you are mounted at the time you enter the portal
#VAR {MountP} {0} {0}1

;// MountedFlag is set if you were mounted when you entered the portal.
#VAR {MountedFlag} {0}

;// Text representation of whether or not MountFlag is set.
#var {MountFlagSet} {No}

;// AutoFlag controls whether or not you automatically remount after spinning, if you are mounted when you enter the portal. On by default
#VAR {AutoFlag} {1} {1}

;// Text representation of whether or not AutoFlag is set
#var {AutoFlagSet} {Enabled}

;// PortalTotal is total portals entered
#VAR {PortalTotal} {0}

;// TotalSeconds is total time spent in portal, in seconds
#var {TotalSeconds} {00}

;// GoodTotal is total good portals entered
#VAR {GoodTotal} {0}

;// GoodSeconds is total time spent in good portals, in seconds
#var {GoodSeconds} {00}

;// SpinTotal is the counter tracking the total number of spins
#VAR {SpinTotal} {0}

;// SpinSeconds is total spin time spent spinning, in seconds
#var {SpinSeconds} {00}

;// TimerStart is the time at which you enterd the portal
#VAR {TimerStart} {0}

;// TimerEnd is the time at which you exited the portal
#VAR {TimerEnd} {0}

;// PortalSeconds is the amount of time spent in the last portal, in seconds
#var {PortalSeconds} {00}

;// Destination is the Portal Destination
#VAR {Destination} {0}

;// autospin command enbles or disables auto portal
#alias {autospin} {#if {@AutoFlag=0} {#var {AutoFlagSet} {Enabled};#var {AutoFlag} {1};#show {%char(10)%char(10)%ansi(bold,yellow)Auto Portal On}} {#var {AutoFlagSet} {Disabled};#var {AutoFlag} {0};#show {%char(10)%char(10)%ansi(bold,yellow)Auto Portal Off}}}

;// Use "en", "ent", or "enter" to enter a portal
#alias {en} {#IF (%null(%1)) {#SHOW {Enter what?}} {#if {@MountP=0} {#var {MountFlagSet} {No};#var {MountedFlag} {0}} {#var {MountFlagSet} {Yes};#var {MountedFlag} {1}};#var {Destination} {%1};ente %-1}}
#alias {enter} {#IF (%null(%1)) {#SHOW {Enter what?}} {#if {@MountP=0} {#var {MountFlagSet} {No};#var {MountedFlag} {0}} {#var {MountFlagSet} {Yes};#var {MountedFlag} {1}};#var {Destination} {%1};ente %-1}}
#alias {ent} {#IF (%null(%1)) {#SHOW {Enter what?}} {#if {@MountP=0} {#var {MountFlagSet} {No};#var {MountedFlag} {0}} {#var {MountFlagSet} {Yes};#var {MountedFlag} {1}};#var {Destination} {%1};ente %-1}}

;// Normal portal trigger
#TRIGGER {You step into the portal and the world fades into the mist.} {settime TimerStart;#ADD {PortalTotal} {1};#ADD {GoodTotal} {1};#emoteall {%ansi(bold,cyan)PORTAL: %ansi(bold,white)Successful entry at %ansi(bold,green)%time(h):%time(n):%time(s)  %ansi(bold,cyan)Dest: %ansi(bold,white)@Destination  %ansi(bold,cyan)Auto: %ansi(bold,white)@AutoFlagSet  %ansi(bold,cyan)Mount: %ansi(bold,white)@MountFlagSet}}

;// Spin portal trigger
#TRIGGER {You step into the portal, and the world spins madly...} {settime TimerStart;#ADD {PortalTotal} {1};#ADD {SpinTotal} {1};#emoteall {%ansi(bold,cyan)PORTAL: %ansi(bold,white)Spin occurred at %ansi(bold,red)%time(h):%time(n):%time(s)  %ansi(bold,cyan)Dest: %ansi(bold,white)@Destination  %ansi(bold,cyan)Auto: %ansi(bold,white)@AutoFlagSet  %ansi(bold,cyan)Mount: %ansi(bold,white)@MountFlagSet}}

;// Normal portal ending
#TRIGGER {and find yourself back in the world of Medievia.} {settime TimerEnd;getsecdiff PortalSeconds @TimerStart @TimerEnd;#ADD {TotalSeconds} {@PortalSeconds};#ADD {GoodSeconds} {@PortalSeconds};chatspinRT}

;// Spin portal ending
#TRIGGER {You stagger out of the portal} {settime TimerEnd;getsecdiff PortalSeconds @TimerStart @TimerEnd;#ADD {SpinSeconds} {@PortalSeconds};#ADD {TotalSeconds} {@PortalSeconds};chatspinRT;#if (@MountedFlag=1) {#ALARM +1 {mount @Mount;#if (@AutoFlag=1) {en @Destination}}} {st;#if (@AutoFlag=1) {en @Destination}}}

;// Set mount name
#TRIGGER {You jump up and mount an %1} {#VAR {Mount} {%1};#IF (@Mount =~ " dragon") {#VAR Mount {dragon}}};
#TRIGGER {You jump up and mount a %1} {#VAR {Mount} {%1};#IF (@Mount =~ " dragon") {#VAR Mount {dragon}}};

;// Show you your spins
#ALIAS {showspin} {#SHOW {%char(10)%char(10)%ansi(bold,cyan)Last Portal: %ansi(bold,white)[@PortalSeconds/3600]:%mod(@PortalSeconds/60,60):%mod(@PortalSeconds,60)   %ansi(bold,cyan)Total: %ansi(bold,white)@PortalTotal %ansi(bold,cyan)~@ %ansi(bold,white)[@TotalSeconds/3600]:%mod(@TotalSeconds/60,60):%mod(@TotalSeconds,60)   %ansi(bold,cyan)Good: %ansi(bold,white)@GoodTotal %ansi(bold,cyan)~@ %ansi(bold,white)[@GoodSeconds/3600]:%mod(@GoodSeconds/60,60):%mod(@GoodSeconds,60)   %ansi(bold,cyan)Spins: %ansi(bold,white)@SpinTotal %ansi(bold,cyan)~@ %ansi(bold,white)[@SpinSeconds/3600]:%mod(@SpinSeconds/60,60):%mod(@SpinSeconds,60)%char(10)}}

;// Chat your spins to your friends
#ALIAS {chatspin} {#EMOTEA {%ansi(bold,cyan)Last Portal: %ansi(bold,white)[@PortalSeconds/3600]:%mod(@PortalSeconds/60,60):%mod(@PortalSeconds,60)   %ansi(bold,cyan)Total: %ansi(bold,white)@PortalTotal %ansi(bold,cyan)~@ %ansi(bold,white)[@TotalSeconds/3600]:%mod(@TotalSeconds/60,60):%mod(@TotalSeconds,60)   %ansi(bold,cyan)Good: %ansi(bold,white)@GoodTotal %ansi(bold,cyan)~@ %ansi(bold,white)[@GoodSeconds/3600]:%mod(@GoodSeconds/60,60):%mod(@GoodSeconds,60)   %ansi(bold,cyan)Spins: %ansi(bold,white)@SpinTotal %ansi(bold,cyan)~@ %ansi(bold,white)[@SpinSeconds/3600]:%mod(@SpinSeconds/60,60):%mod(@SpinSeconds,60)%char(10)}}

;// AutoChat at the end of a portal
#ALIAS {chatspinRT} {#emoteall {%ansi(bold,cyan)exits the portal after %ansi(bold,white)[@PortalSeconds/3600]:%mod(@PortalSeconds/60,60):%mod(@PortalSeconds,60)   %ansi(bold,cyan)Total: %ansi(bold,white)@PortalTotal %ansi(bold,cyan)~@ %ansi(bold,white)[@TotalSeconds/3600]:%mod(@TotalSeconds/60,60):%mod(@TotalSeconds,60)   %ansi(bold,cyan)Good: %ansi(bold,white)@GoodTotal %ansi(bold,cyan)~@ %ansi(bold,white)[@GoodSeconds/3600]:%mod(@GoodSeconds/60,60):%mod(@GoodSeconds,60)   %ansi(bold,cyan)Spins: %ansi(bold,white)@SpinTotal %ansi(bold,cyan)~@ %ansi(bold,white)[@SpinSeconds/3600]:%mod(@SpinSeconds/60,60):%mod(@SpinSeconds,60)%char(10)}}

;// Reset your portal stats
#ALIAS {clearspin} {#var {PortalTotal} {0};#var {SpinTotal} {0};#var {GoodTotal} {0};#var {MountFlagSet} {No};#var {TimerStart} {0};#var {TimerEnd} {0};#var {PortalSeconds} {0};#var {TotalSeconds} {0};#var {SpinSeconds} {0};#var {GoodSeconds} {0};#SHOW {%char(10)%char(10)%ansi(bold,yellow)Portal Statistics Reset%char(10)}}

;// Help text
#ALIAS {phelp} {#show {%char(10)%char(10)%ansi(bold,white)ͻ%char(10)%ansi(bold,green)autospin    %ansi(bold,white)%ansi(bold,cyan)Toggles autospin on or off                               %ansi(bold,white)%char(10)Ķ%char(10)%ansi(bold,green)enter %ansi(bold,white)~<%ansi(bold,yellow)DEST%ansi(bold,white)~>%ansi(bold,cyan)Use this command to enter the portal                     %ansi(bold,white)%char(10)%ansi(bold,green)ent   %ansi(bold,white)~<%ansi(bold,yellow)DEST%ansi(bold,white)~>%ansi(bold,cyan)Use this command to enter the portal                     %ansi(bold,white)%char(10)%ansi(bold,green)en    %ansi(bold,white)~<%ansi(bold,yellow)DEST%ansi(bold,white)~>%ansi(bold,cyan)Use this command to enter the portal                     %ansi(bold,white)%char(10)Ķ%char(10)%ansi(bold,green)showspin    %ansi(bold,white)%ansi(bold,cyan)Displays your current spin statistics                    %ansi(bold,white)%char(10)%ansi(bold,green)chatspin    %ansi(bold,white)%ansi(bold,cyan)Displays your current spin statistics to everyone on chat%ansi(bold,white)%char(10)Ķ%char(10)%ansi(bold,green)clearspin   %ansi(bold,white)%ansi(bold,cyan)Resets your current spin statistics                      %ansi(bold,white)%char(10)ͼ%char(10)%ansi(bold,red)         NOTE: For auto mount detection to work, 2 triggers%char(10)               must be edited to match your command prompt%char(10)}}
#CLASS 0