Skip to content

Lua functions

Vuthakral edited this page May 17, 2023 · 7 revisions

[S] : Server-sided
[C] : Client-sided
[S/C] : Both realms.

[S/C] : CTFK(<tab> table, <value> string)
"Check Table For Key". Runs through a table and returns true/false if it contains the given string or not.

  • tab : The table to run through
  • value : The string (key) to look for.

[C] : ReturnKey( <action> string )
Gets the key bound to a given keybind string. e.g. `+attack". Returns "<NO KEY>" string if no key is bound. Returns the bound key as a string otherwise.

[S] : DRC:EmitSound(<source> entity, <near> sound, <far> sound, <distance> integer, <enum> hint)
The function is used to play a scripted sound with near/far sounds. DSP is automatically handled.

  • source: The entity that the sound originates from
  • near : The sound to play when inside the minimum distance
  • far : The sound to play when outside the minimum distance, on top of near.
  • distance : The distance the player must be from the source to hear the far sound.
  • hint: The hint for NPCs to understand what this sound is. See https://wiki.facepunch.com/gmod/Enums/SOUND

[S/C] : DRC:GetVersion()
Returns the version number of the Draconic Base currently running.

[S/C] : DRC:GetColours(<entity> ent, <bool> rgb)
Get the current Draconic colour settings from a given entity. the RGB bool (true/false) is whether these values should be returned as 0-255 RGB or 0-1 Decimal.

[S/C] : DRC:UpdatePlayerColours(<player> ply)
Force-updates the Draconic colour settings of a player. In multiplayer, this must be called on the server to update permanently & for all clients.

[S] : DRC:AddText(<player> ply, <table> varargs)
A server-networked version of https://wiki.facepunch.com/gmod/chat.AddText

[S/C] : DRC:Interact(<player> ply, <bool> prevent movment, <entity> interacted ent)
Hides the player's viewmodel, and can prevent them from moving. Disables firing of weapons from direct input, and instead passes the input to the interacted entity (optional).

[S/C] : DRC:BreakInteraction(<player> ply, <entity> ent)
Breaks the DRC:Interact() currently running on a player. Entity optional.

[S/C] : DRC:ProjectedTexture(<entity> ent, <attachment number> att, <table of settings> tbl)
Unfinished, experimental.

[S/C] : DRC:RemoveAttachedLights(<entity> ent)
Removes projected textures added via the Draconic Base.

[C] : DRC:DLight(<entity> ent, <vector> pos, <color> col, <int>size, <time in seconds>lifetime, <bool>emissive) Creates a parented DLight on the specific entity at the specified position, auto-corrects for LDR & emissive use when creating a non-elight.

[S/C] : DRC:GetSWLightMod()
Returns a vector intended to be used for colour tinting with the Simple Weather's modified lighting.

[S/C] : DRC:EyeCone(<player> ply, <number> dist, <number> degree)
Run a cone on a player's EyePos with the given parameters above. Returns the results.

[C] : DRC:GetSpray(<player> ply)
Returns a .vtf texture of the given player's spray.

[S/C] : DRC:AddAmmoType(<table> tbl)
Registers an ammo type using the given table format:

local batteryammo = {
	Name = "ammo_drc_battery",
	Text = "Don't give yourself this ammo. It will only break your weapons.",
	DMG = DMG_BULLET,
	DamagePlayer = 0,
	DamageNPC = 0,
	Tracer = TRACER_LINE_AND_WHIZ,
	Force = 500,
	SplashMin = 5,
	SplashMax = 10,
	MaxCarry = 100,
}
DRC:AddAmmoType(batteryammo)

[S/C] : DRC:ParticleExplosion(<Vector> pos, <Number> magnitude, <Number> distance)
Creates a dynamic particle effect like an explosion. Handles all physics, colours, sizes, and etc automagically.

[S] : DRC:CallGesture(<entity> ent, <gesture slot> slot, <activity name> act, <bool> autokill)
Calls an activity to be played on a given entity. See this page for a list of valid gesture slots.

[S/C] : DRC:RoomSize(<entity or vector> pos): Returns a "size score" of a room based on a given position. If called on a player/NPC/NextBot it will use their EyePos instead.

[S/C] : DRC:GetRoomSizeName(size) -- To be used with DRC:RoomSize() (see above). Returns a string of the general "room size" by Draconic definitions. Possible returns, in order from smallest to largest, are as follows:

  • Vent (EXTREMELY tiny)
  • Small (Uncommon)
  • Regular (Very common)
  • Large (Common on gm_ style maps as they tend to have huge rooms)
  • Outdoors (Uncommon but not as uncommon as small, very high world ceilings often cause Valley instead of this, but narrow passageways / alleyways are likely to cap it back down to this)
  • Valley (Very common in outdoor environments)
Clone this wiki locally