Skip to content

New libraries

dounai2333 edited this page Jan 24, 2025 · 3 revisions

Introduction

These are small group of functions piece together and be a useful library.

For example, you need a timer that will execute something after 3 seconds, but running EventManager:RegisterTimer() and creating special function is annoying.

You can now do this instead:

local message = "I'm the message that will show after 3 seconds!"

dounai_lib.timer.Simple(3, function()
    print(message) -- Output: "I'm the message that will show after 3 seconds!"
end)

Or, you need every entities in the game, however the original GetEntityList() is awful and ignoring players.

You can now do this instead:

-- Contain every single valid entity current in the game, including worldspawn, players, networked-entities and server-side only non-networked entities.
local entities = dounai_lib.ents.GetAll()

-- Print all entities to console. using `ipairs` will gain better performance and are more secure.
for k, v in ipairs(entities) do
    print(v)
end
printf("Current game has %d entities!", #entities)

Table of contents

Libraries are needed to use another page to properly format.

  1. cfg
  2. csv
  3. ents
  4. player
  5. timer

Clone this wiki locally