Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

Lua entities in SourceOP
#1

It's still in development and early stages, but I got Lua entities in SourceOP working. Lua scripters can make their own custom entities and can spawn them in SourceOP or any other plugin capable of spawning entities. It works similar to how Garry's mod works so that it is familiar to those with experience using Garry's mod.

Example:

lua/entities/sop_luatest2/info.lua
Code:
ENT.Type        = "anim"
ENT.Base        = "base_entity"

ENT.PrintName        = "Test Entity2"
ENT.Author        = "Drunken F00l"
ENT.Contact        = ""
ENT.Purpose        = "Test Entity2"
ENT.Instructions    = "Spawn and watch in awe as the test entity works."

lua/entities/sop_luatest2/init.lua
Code:
include('info.lua')

function ENT:Precache()
  util.PrecacheModel("models/props_c17/furniturebathtub001a.mdl")
end

function ENT:Initialize()
  Msg(self.PrintName .. ": Hi. Spawned at (" .. tostring(self:GetAbsOrigin()) .. ")\n")
  self:SetModel("models/props_c17/furniturebathtub001a.mdl")
  self:PhysicsInit(SOLID_VPHYSICS)
end

function ENT:Think()
  return false
end

This entity spawns as a bathtub and prints a message in the server console saying where it spawned when it spawns. Real basic, I know, but there is lots of potential with this. Hopefully I will be able to code the radio and snark completely in Lua.
Reply


Messages In This Thread
Lua entities in SourceOP - by Drunken F00l - Mar 10, 2008, 02:31 AM
Lua entities in SourceOP - by Hell-met - Mar 10, 2008, 03:17 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)