Thread: Porters
View Single Post
  #19  
Old 04-17-2015, 05:35 PM
Asylum
Sarnak
 
Join Date: Jun 2013
Posts: 81
Default

Congratulation on solving your puzzle. Now to tackle simplifying the code. As many have advised over the years, using an array or hash to handle multiple inputs and outputs is the best method to simplify code.

Basically you have a player /say "location" as input to the npc's EVENT_SAY subroutine, which triggers the wonderful spell animations and invis prior to porting to the various destinations as output. The inputs can be stored as a variable $playersaidthis and the outputs as a variable $portplayerhere in an associated array.

Your code will have a single if statement instead of an if/elsif for every destination and be about 90% shorter. Let us know how it works and once again, congratulations on solving your perl puzzle and learning more about scripting.

EDIT: haha, I forgot to hit send this morning and after I realized it this afternoon, ghanja had already posted the script I described.
Reply With Quote