[LUAmmer]
A simple API that allows you to "inject" lua code into hammer maps. Fast and simple. Entries can be added using entity names, classes, or positions. Everything is fully networked. Great for adding extra functionality or applying fixes for engine entities.
-
LUAmmer.AddEntry(map, nameORclassORpos, func)
Used to add LUAmmer entries. Entries get only added when the specified map gets loaded.
mapEntries will be loaded only if the specified map is loadednameORclassORposName, class, or position of an entity that you wish to inject lua tofuncPretty much an Initialize function, here you can apply your code. Mind that it i shared between the server and the clientsExamples:- Of using the entity’s class:
LUAmmer.AddEntry( "testroom2_extended", "npc_citizen", function(self) –Code end )
- Of using the entity’s name:
LUAmmer.AddEntry( "testroom2_extended", "thomas", function(self) –Code end )
- Of using the entity’s position:
LUAmmer.AddEntry( "testroom2_extended", "254 2001 -450", function(self) –Code end )
- Of using multiple identifiers:
LUAmmer.AddEntry( "testroom2_extended", "thomas_1, thomas_2, thomas_3", function(self) –Code end )
- Of using the entity’s class:
-
LUAmmer.RemoveEntry(nameORclassORpos)
Used to remove entries from the LUAmmer. Really should be used only when working on a map.
nameORclassORposName of the entry that you wish to remove. -
LUAmmer.CreateVar(ent, var, val)
Used to create variables for entities that should be saved by duplication tools (Duplicator and Adv. Duplicator 2). Once set, it can only be changed via SetVar function
entEntity that you want to create a variable forvarName of your variablevalValue of your variableExample:- Of creating a variable "m_bCanBeUsed". Now it can be overridden with SetVar to false and it will load as such when loading a save:
LUAmmer.CreateVar(self, "m_bCanBeUsed", true)
- Of creating a variable "m_bCanBeUsed". Now it can be overridden with SetVar to false and it will load as such when loading a save:
-
LUAmmer.SetVar(ent, var, val)
Used to change/override saved variables
entEntity that you want to override a variable forvarName of your variablevalValue of your variable -
ENT:LUAmmerOutputHook(entOutput, func)
Used to add functions to entity outputs (I/O)
entOutputName of an output (OnPlayerPickup for an example)funcFunction to run when output gets firedExample:- Of using prop_physics’s "OnPlayerPickup" output which runs when players pick it up by hand or via the gravity gun:
prop:LUAmmerOutputHook("OnPlayerPickup", function(self, activator, caller) — Code end)
- Of using prop_physics’s "OnPlayerPickup" output which runs when players pick it up by hand or via the gravity gun:
-
ENT:LUAmmerRelatedEntity(name)
Used to easily get a reference of entities related to our entity via name and ID. This function will search for the entity with the provided name and return the first match. If your entity doesn’t have an ID ("tank_turret" and no digit at the and) or has no name at all, the function will look for an entity with an exact provided name.
nameName of the entity (tank_turret for an example)Example:- Of finding an entity related to ours. Our entity’s name is "tank_turret1" in this example:
local seat = self:LUAmmerRelatedEntity("tank_seat")
Since our entity’s name was "tank_turret1", function looked for an entity named "tank_seat1" and returned it (if found)
- Of finding an entity related to ours. Our entity’s name is "tank_turret1" in this example:
CREDITS:
tags: testroom2 hl2beta beta
Revisions:
Old revisions of this mod are available below. Click the link to download.