• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua creaturescript interval (1.x branch master)

zbizu

Legendary OT User
Joined
Nov 22, 2010
Messages
3,329
Solutions
27
Reaction score
2,720
Location
Poland
How do I set custom interval for onThink creaturescript?

Code:
<event type="think" name="eventThink" interval="7000" script="event.lua" />

I did that registering stuff, etc. and it's always 1000 when it's executed.

no interval in creaturescripts.xml:
print(interval) -> 1000
any number(0, 100, 2000):
print(interval) -> 1000

Does it even care about other intervals than 1000? I can't find where the number is set in sources.


(actually I needed interval smaller than 1000, did workaround with addEvents in a loop. I'm still curious if it's possible to set custom interval without source edits, though)
 
Last edited:
OnThink interval is always 1 second. Tfs calls each creature onThink function every 1 second and each creature onThink creaturescript event every 1 second. If you want a smaller time, you need to edit EVENT_CREATURE_THINK_INTERVAL in creature.h file. Be aware that you will change the on think delay for every creature(npcs, monsters, players).
 
dont want some addEvents and no source edits? no way

you can create a new checkCreaturesList to follow your own rule

related funcs:
Code:
        void addCreatureCheck(Creature* creature);
        static void removeCreatureCheck(Creature* creature);
        void checkCreatureWalk(uint32_t creatureId);
        void checkCreatureAttack(uint32_t creatureId);
        void checkCreatures(size_t index);
 
I know I can create anything with source edits.
My goal is to always do scripts entirely in Lua to make them compatible with clear tfs, sadly a couple of commits later they drop errors, lel.
Hardcoded interval has no influence on a thing I'm currently working on because I find it very easy to write a clock-like workaround based on variable and timers.
Was just curious if it was scripted in tfs sources to force a different interval via xml file, nvm.
 
Back
Top