EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Quests::LUA (https://www.eqemulator.org/forums/forumdisplay.php?f=680)
-   -   Adding a pause to scripts (https://www.eqemulator.org/forums/showthread.php?t=42587)

jsr 08-29-2019 12:34 AM

Adding a pause to scripts
 
I'm trying to add a pause to an NPC script between statements while preserving the if block. So ideally, without using event_timer.

I tried using the threadmanager's wait function, but it doesn't do anything. I've referenced the example in http://wiki.eqemulator.org/p?Lua_NPC_Examples

This is from the example
Code:

local ThreadManager = require("thread_manager");
local evt;
 
function ability_one()
    evt.self:Emote("begins to cast something electrical");
    ThreadManager:Wait(2.5);
    evt.self:Shout("Feel the thunder!");
end


This is my implementation
Code:

function event_say(e)

        local tm = require("thread_manager")
       
        if e.message:findi("hail") then
       
                e.self:Say("A message")
                tm:Wait(5)
                e.self:Say("B message")
                tm:Wait(5000)
                e.self:Say("C message")
        end
end

A, B, and C message all display at once, and no quest errors are generated. Does anyone know why this wouldn't work?

Gnowm 09-07-2019 06:16 PM

Just a guess but punctuation kills me so

Lack of semicolon after tm:Wait(5)

Dont know lua though.

jsr 09-08-2019 10:33 AM

Thanks for the response Gnowm.

Lua is forgiving if you don't use semi colons :) It's actually not good because nearly every other language uses them, and after a few hours of being lazy with Lua I end up missing them when I go back to other projects.

I did work this out in the end, but not with the thread manager, which is probably not fit for purpose in this case. I wound up using qglobals to store a condition, and a heartbeat timer to check for the condition and act accordingly.

demonstar55 09-08-2019 06:05 PM

You need to use a timer

jsr 09-08-2019 08:14 PM

cheers Demonstar :)

demonstar55 09-08-2019 11:19 PM

PEQ quest repo has a few examples.

Akkadius 09-09-2019 12:38 AM

An example can also be found here on our not yet announced new documentation :)

https://eqemu.gitbook.io/quest-api/events#event_timer

Huppy 09-09-2019 12:47 AM

Quote:

Originally Posted by Akkadius (Post 263411)
An example can also be found here on our not yet announced new documentation :)

https://eqemu.gitbook.io/quest-api/events#event_timer

Wow. I am loving the function on those pages. Seeing the examples shown in both perl and lua. Here's a big (not yet announced) Thank You ;)

Gnowm 09-09-2019 06:57 AM

I cant correctly express my gratitude. Youve basically enabled
this numbskull to learn and play.
Great examples and answers both on the wiki and the forum.

Kudos and thankyou all.


All times are GMT -4. The time now is 08:33 AM.

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