EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::Q&A (https://www.eqemulator.org/forums/forumdisplay.php?f=599)
-   -   Calls to function Lua (https://www.eqemulator.org/forums/showthread.php?t=37173)

rencro 08-13-2013 07:47 PM

Calls to function Lua
 
I see many of the new quest written in lua are using what looks like calls to other functions within functions, for example, in guktop, croc_spawns makes a call from event_spawn to croc_spawns();

I cant get this behavior to work on either my windows or linux boxes, here is my test quest I tried when I ran into trouble:

Code:

function event_spawn(e)
        e.self:SetRunning(true);
        e.self:Shout("HELLO!!!");
        croc_spawn();
end

function event_say(e)
        if(e.message:findi("hail")) then
                e.self:Say("This works.");
        end
end

function event_waypoint_arrive(e)
        if(e.wp == 1) then
                e.self:Shout("Im at waypoint 2!!");
        end
end

function croc_spawn()
        e.self:Shout("Hi there welcome to Kmart");
end

When mob spawns I get the initial shout, then croc_spawn is not processed, then when mob arrives at wp 1 I get the shout, also, if I put in an event such as a shout in the event_spawn AFTER calling for croc_spawn, that does not process either, so, how does this work? Assuming these are working on peq maybe im missing something in my setup??

sorvani 08-13-2013 07:53 PM

e does not exist in croc_spawn

You need to pass it if you are going to use it.

Code:

function event_spawn(e)
    croc_spawn(e);
end

function croc_spawn(e)
    e.self:Shout("hey!");
end


rencro 08-13-2013 08:18 PM

Thanks, that fixed this test script and my actual spawning script

Code:

-- abe the abandoned custom

function event_spawn(e)
        e.self:SetRunning(true);
end

function event_say(e)
        if(e.message:findi("hail")) then
                e.self:Say("Lets just get this done.");
        end
end

function event_waypoint_arrive(e)
       
        if(e.wp == 1) then
                eq.unique_spawn(98051,14,0,661.77,-1774.69,3.78,78.5); -- spawns dillon
        elseif(e.wp == 2) then
                e.self:Emote("runs up besides you");
                e.self:SetRunning(false);
        elseif(e.wp == 3) then
                e.self:Emote("grabs a long bamboo pole from the hut.");
                eq.signal(98036,1,5000);
        elseif(e.wp == 4) then
                e.self:Say("Ok, I'm going to use this stick to knock down the ripe fruit, be ready to pick up any that fall to the ground, only the ripe ones will fall.");
        elseif(e.wp == 5 or e.wp == 7 or e.wp == 9) then
                e.self:Emote(eq.ChooseRandom("bangs his bamboo stick against the branches in the upper part of the tree.","raises his stick into the branches"));
        elseif(e.wp == 6) then
                e.self:Say("I see a couple dropping now, grab them up!");
                eq.create_ground_object(30619, 993.07, -1533.8, 34.59, 0, 30000);
                eq.create_ground_object(30619, 999.44, -1567.8, 45, 0, 30000);
        elseif(e.wp == 8 or e.wp == 10) then
                Ground_Stuff(e);
        end
end

function event_signal(e)
                e.self:Say("Let's go.");
end       

function Ground_Stuff(e)
        local xloc = e.self:GetX();
        local yloc = e.self:GetY();
        local zloc = e.self:GetZ();
        local RandomNumber = 0;
        RandomNumber = math.random(100);
       
        if(RandomNumber <=45) then
                e.self:Say(eq.ChooseRandom("Nothing.","Hmm..","Oh well.","On to the next one.","Moving right along"));
        elseif(RandomNumber > 45 and RandomNumber <= 75) then
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
        elseif(RandomNumber > 75 and RandomNumber <= 90) then
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
        elseif(RandomNumber > 90 and RandomNumber <= 95) then
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
        elseif(RandomNumber > 95 and RandomNumber <= 98) then
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
        elseif(RandomNumber > 98) then
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
                eq.create_ground_object(30619,xloc + math.random(-20,20),yloc + math.random(-10,10),zloc+25,0,15000);
        end
end

A blatant plagarism of existing quests, no credits intended for me..


All times are GMT -4. The time now is 07:29 AM.

Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.