Oh I can’t believe I forgot that part! That’s right there’s no use editing the lua files, unless you want to change some defaults. Here’s an example usage :
function SpawnExplosion( ply ) //This function will be called trough a console command which passes the player object.
tr = ply:GetEyeTrace() // Creating a line from the player's line
if !tr.Hit then return end //If it hit nothing end the execution
exp = ents.Create("simple_explosion") //Creating the explosion entity
//Setting up the explosion's properties, note that they are ALL optional.
exp.Radius = 150 // Changing the default Radius
exp.Damage = 70 // Changing the default Damage
exp.Delay = 0 // This already is the default so I could leave this line out
exp.Cheap = true// Making it so a cheap explosion is used
exp.Manual = false // Not manual, if it's not set to true I can leave that part out and it won't change a thing.
exp.Repeatable = false // It will remove itself after exploding
exp:SetPos( tr.HitPos ) // Positioning the explosion where the line of the player's eyes hit
exp:Spawn() // Creating and activating the explosion.
concommand.Add( "Explosion", SpawnExplosion ) // Linking the SpawnExplosion function to the console command Explosion, it can be bound to a key.
I made that example with every property possible used, this one allows for quick spamming of the explosions and it’s a lot of fun ;).
Note that all properties are optional, the defaults are 0 seconds delay, 200 radius, 100 damage and every other option turned off.
What’s really important when spawning the explosion (or any entity) is setting it’s class, it’s position and then spawning it. The rest can be ignored.
As for quickly experimenting I suggest you run garrysmod in windowed mode. There are also a few commands you can take advantage of. (Btw when testing I suggest you take Wiremod, phx and other big addons off your addons folder because it slows you down tons.)
gamemode_reload (reloads the gamemode)
gamemode_reload_cl (reloads the gamemode from the client’s perspective)
lua_run (Run any lua code with this)
lua_run_cl (Run lua code as a client)
lua_openscript (Open or reload a lua file. You could test your code in a file in garrysmod/lua and simply reload it with this.
lua_openscript_cl (Same thing but clientside)
lua_reloadents (Reloads all scripted entities and sweps, might take a moment with big addons installed)
lua_reloadent (Reloads a single entity/swep. Must be downloaded first.)
And here’s a really useful addon :
Luapad (Allows you to code ingame and test your code on the run!
There, I hope I didn’t forget anything.