Creating a Portal using LUA
By Gastricpenguin
Since we know making portals straight from the DB is only so limited, we can begin to take an easier approach and use LUA to make portals instead of wasting spells.
Step 1, Getting the coordinates
Very simple, go ingame and find the place you want the portal to lead to. Once there use the .gps command, and copy down: The map #, X, Y, and Z coordinates.
Step 2, Creating the LUA script
Open up any text editor (like notepad), then copy and paste the following code:
NOTE: Anything highlighted in green, such as Teleporting_onUse MUST be different for every portal!Code:function Teleporting_onUse (pUnit, Event, pMisc) pMisc:Teleport (MAPID, X, Y, Z) end RegisterGameObjectEvent (ENTRY, 2, "Teleporting_onUse")
You can change "Teleporting_onUse" on the top line to anything you want, but make sure it says the same thing in the bottom line. Entering the coordinates into the script should be self explanitory. Just note that "ENTRY" must be the same value as the ENTRY in your gameobject. Save this as a .lua and put it in your scripts folder
Step 3, Creating the Gameobject
Here is a simple template to create your gameobject:
Just change ENTRY to the number you used to fill in for ENTRY in the Lua script. You can rename the portal to anything you want to aswell.Code:INSERT INTO gameobject_names (entry, Type, DisplayID, Name, spellfocus, sound1, sound2, sound3, sound4, sound5, sound6, sound7, sound8, sound9, unknown1, unknown2, unknown3, unknown4, unknown5, unknown6, unknown7, unknown8, unknown9, unknown10, unknown11, unknown12, unknown13, unknown14) VALUES (ENTRY, 4, DISPLAYID, "NAME", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
If you have any errors or problems, show me your script and Gameobject and i will fix them