Need some Lua help =P menu

User Tag List

Results 1 to 4 of 4
  1. #1
    tyeeeee1's Avatar Member
    Reputation
    6
    Join Date
    Feb 2008
    Posts
    95
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need some Lua help =P

    I'm currently scripting a starting zone for my server within the instance of Scholomance, currently I've run into a small roadblock. I've attempted to figure out how to do range checks to stop the player from advancing to far into the dungeon but it doesn't seem to work, although I did managed to get it working once (but that was a few versions ago so I can't go back to that version of the script).
    If anyone has a few minutes to look over my script to see what I did wrong it would help =)

    [Lua] -- This script was created with the help of Rotchet2, Crow, and Bjarke local - Pastebin.com

    The range check function is initialized on line 27 and the function itself is on line 152.
    Last edited by tyeeeee1; 07-19-2012 at 05:17 PM.

    Need some Lua help =P
  2. #2
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Try this:

    Code:
    function CheckIfInRange_Whitemane90003(Whitemane)
    	local player = Whitemane:GetClosestPlayer()
    	local unit = Whitemane:GetCreatureNearestCoords(262.055908, 64.339806, 109.901627, 29138)
    	if unit == nil then
    		print("ERROR : unit is null in CheckIfInRange_Whitemane90003 function.")
    		return
    	end
    	if player == nil then
    		print("ERROR : nearest player was null in CheckIfInRange_Whitemane90003 function.")
    	end
    
    	local distance = unit:GetDistanceYards(player)
    
    	if player:HasQuest(90003) and distance <= 5 then
    		Whitemane:RegisterEvent("Necromancer1_Whitemane90003", 2000, 1)
    	else if (not player:HasQuest(90003)) and (distance <= 5) then
    		Whitemane:SendChatMessage(42, 0, "A strange force prevents me from advancing further.")
    		player:MovePlayerTo(262.464417, 37.656471, 115.727440, 1.565179, 256, 0)
    	end
    end

  3. #3
    tyeeeee1's Avatar Member
    Reputation
    6
    Join Date
    Feb 2008
    Posts
    95
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, thanks for the revision. The range check works as intended now and I've also learned how to do error checks thanks to your script.

  4. #4
    stoneharry's Avatar Moderator Harry


    Reputation
    1618
    Join Date
    Sep 2007
    Posts
    4,564
    Thanks G/R
    151/150
    Trade Feedback
    0 (0%)
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    I missed a return in my second error check.

    Return just makes the function stop there (as if it was a end) and return to where it was. This also allows you to return values:

    return 0

    Then you can do:

    if function(unit) == 1 then

    And you tell it to return 0, or return 1, depending on where it gets to.

Similar Threads

  1. Making an addon, need some LUA help
    By gryphons53 in forum WoW UI, Macros and Talent Specs
    Replies: 1
    Last Post: 12-30-2009, 02:39 AM
  2. I need some Lua help please. Great concept.
    By TripZone in forum WoW EMU Questions & Requests
    Replies: 4
    Last Post: 08-01-2009, 02:01 PM
  3. Need some LUA help!
    By grothar1993 in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 04-18-2009, 07:36 AM
  4. I need some Lua help,
    By Kiev in forum WoW EMU Questions & Requests
    Replies: 11
    Last Post: 12-24-2008, 04:19 PM
  5. i need some lua help please
    By runiker in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 02-29-2008, 07:49 AM
All times are GMT -5. The time now is 02:47 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search