Making a slapping weapon from the watch weapon I made for Elevator: Source, then this happened..
Making a slapping weapon from the watch weapon I made for Elevator: Source, then this happened..
They aren't true prepared statements though
Seven Swords stuffs
that is some fucking sexy stuff
it serves its purpose though
Finally, a realistic kick that does not explode the enemy.![]()
That looks fantastic. I assume you've made it easy for yourself to put it on either side of the screen? (My visual opinion is that it would look better on the left.)
Optimised the internals of the userdata system, FPS in a timedemo went from 127 to 140, which isn't that significant but the demo wasn't very heavy Lua-wise - so I'm guessing it will scale a lot.
I moved the timer function to engine code. Nothing changed - still completely compatible. This should please everyone that was moaning about timers taking down their whole gamemode. They act like they did with pcall now - and get removed when they error (and when they error they tell you the timer name and where it was created/adjusted).
Hook next - I expect to see a hefty performance boost from that.
Haha, great job, thanks. I knew you'd fix it eventually!
You're right, this seems to be the better option.
Thanks. :)
It was actually a lua job, i made it for Q4-Bi's TTT server. I just tried it on the right side of the screen and I think it fitted nicely.
Might aswell introduce them in a OO way?
Like, use the current system, add the oo system, and after a while, remove the old system.
Edited:
Also nice to see that you pay attention to performance after all!
Oh dear
If hook gets moved to C++ I'm gonna have to do something rediclously hacky, oh well
Edited:
But yes, it should be a lot faster, so go for it
Because i'm such a motherfucking boss i went and remade the default flashlight in Lua.
Pros:
- All done in Lua, using an env_projectedtexture.
- Customizable color, length, radius, flashlight texture, shadow settings.
Cons:
- It's all fucking serverside because ents.Create doesn't exist on the client anymore.
- IT'S ALL FUCKING SERVERSIDE. I dunno what the performance hit of 20 projected textures all being used at once would be but i'd hazard a guess that it will shit all over your FPS.
If possible it would be nice to be able to create these on the client. Why did ents.Create get removed from clientside anyhow?
Was annoying me, so I added the ability to force texture filtering. I enabled it by default between 3d2d camera calls, but will add a binding so it can be done at will (including when rendering html).
![]()
If you set the owner of the projected texture to the player it will use cheap shadows unless LocalPlayer() == owner (cheap shadows means no shadows).
I've disabled dynamic shadows on this flashlight using keyvalues because they make my gamemode unfair. Dynamic shadows are the reason i've had to go and replace the default flashlight altogether. I made a request thread for a function that lets us disable these shadows on a per-entity basis but no dice.
You can see here that it's really easy to spot something invisible that casts shadows if you use the default flashlight. So far this custom flashlight is the only way i've managed to make those shadows disappear.
20 projected textures with no shadows should be ok I suppose.
Can you explain this? I'm curious.
I've experimented a lot with userdata implementations and ended up using light userdata as a key and a table instead of full userdata.
pseduo code:
function Push(pointer, meta) REGISTRY[pointer] = REGISTRY[pointer] or setmetatable({__ptr = pointer}, meta) end function Get(pos) local obj = STACK[pos] return cast(obj.__ptr) end
This means when you push entities to lua it won't create any new userdata if it has already been pushed once. It will just reuse.
When I'm done with the entity I just remove the table from the registry and set its metatable to a NULL one.
Yeah the entity system already does that.
The issue I had was that when I was pushing userdata I was allocating and pushing a pointer.. so when it came to look up the type I was pushing the meta table and getting the typeid which was stored on it.
So instead of doing that stupid shit I store a generic struct as the userdata, which has the typeid and a data pointer.
This is a bit of a speed up because pretty much every call to an entity, or vector, or whatever, looks at the type.. so instead of pushing a table, looking up a member blah blah blah. It just converts the userdata and looks at the type id.
How'd you get it to maintain the player's angles? I tried using a projectedtexture in my gamemode but when I set the player to be the parent not only is it laggy, but it just faces Angle(0, 0, 0) for everyone not in first person.
ie. if I'm looking at another player's flashlight, it faces 0 0 0. If I'm looking at my own flashlight from 3rd person, it faces 0 0 0. If I'm looking at my own flashlight from 1st person, it's correct, if laggy.
A clientside alternative would be the shit.
function meta:LuaFlashlight( on ) if on then local c = Color( 255, 255, 200 ) local b = 4 // brightness local size = 50 if self:GetLoadout( 3 ) == UTIL_LIGHT then b = 6 size = 55 end self.FlashlightEnt = ents.Create( "env_projectedtexture" ) self.FlashlightEnt:SetParent( self ) self.FlashlightEnt:SetLocalPos( Vector(0,0,64) ) self.FlashlightEnt:SetLocalAngles( Angle(0,0,0) ) self.FlashlightEnt:SetKeyValue( "enableshadows", 0 ) self.FlashlightEnt:SetKeyValue( "farz", 512 ) // distance of light self.FlashlightEnt:SetKeyValue( "nearz", 12 ) //12 self.FlashlightEnt:SetKeyValue( "lightfov", size ) // size of light self.FlashlightEnt:SetKeyValue( "lightcolor", Format( "%i %i %i 255", c.r * b, c.g * b, c.b * b ) ) self.FlashlightEnt:Spawn() self.FlashlightEnt:Input( "SpotlightTexture", NULL, NULL, "effects/Flashlight001.vmt" ) self:EmitSound( "items/flashlight1.wav", 50, 110 ) else if IsValid( self.FlashlightEnt ) then self.FlashlightEnt:Remove() self:EmitSound( "items/flashlight1.wav", 50, 90 ) end end end
Wow, just wow. I literally jumped out of my chair when I saw this!
Maybe instead of an fps expensive flashlight, just make the flashlight twitch and burn out when you get within a certain distance from the invisible dude. That would make things way more scary.
Or even when they flash the light on the invisible dude, then you could have it burn out so they get to see him for a second then he is gone and that player loses his light.
How about you're using the players EyeAngles() to determine the correct angle for the env_projectedtexture-entity?
Currently your flashlight runs on battery power, so you can't keep it on forever. The problem is, with 20+ players there will be times where every player has their flashlight on. In this case, it would be smarter to just have clientside flashlights.
But i am at the mercy of what garry decides to do with gmod lua so if he decides to allow certain ents to be spawnable clientside then i'm making this code clientside.
gb-radial converted to gmod 13:
https://dl.dropbox.com/u/15312597/lu...0gmod%2013.zip
I take no credit for this mod. I only updated it to gmod 13.
Change your avatar and i'll buy you a new title.
I made a simple library for editing the new skypaint entity, and some spawnmenu options. It's up on workshop now.
You can grab the code here, go make some cool stuff. I expect to see some audio visualizers in a few days. I left in a FadeTo function which could be abused for cool purposes too.![]()
env_projectiletexture is that expensive?
twoski, you can create a clientsidemodel instead
run something on the client to move each player's flashlight clientsidemodel entity infront of their respected players, and use this entity as a basis for the flashlight
compromises must be made i suppose
how exactly would a clientside prop emit light? they are basically the same as a prop_physics but without a physics mesh. I am asking for the ability to create entities other than physics props on the client.
Projected Texture, you mean. But yes, they seem to be... my framerate started dipping when i was messing around with several of them in sandbox (the lamp entity in sandbox uses them).
This should have been in vanilla gmod tbh.
oh, I see
I thought your issue was having a clientside entity other than using the players themselves
also I completely missed this post
Back on the rape swep...
http://www.facepunch.com/showthread.php?t=1195105
She's happy so I'm happy
So since GLON was removed, and I don't like JSON, I created my own 'database system' that saves shit to .txt files, reads info from the files and organizes them into ready tables to use.
This is a major breakthrough for me, because I did this with no proper knowledge on how databases are coded and/or work. It's also slow as shit, but I don't give a fuck.
It takes 35 seconds to process this:
stealth_p228=1:2,2:2,3:2,4:2,5:1 stealth_deagle=1:2,2:2,3:4,4:1,5:1 stealth_fiveseven=1:3,2:2,3:2,4:4,5:1 stealth_glock18=1:5,2:2,3:2,4:1 stealth_usp=1:2,2:1,5:1,4:3,3:2
into this:
stealth_p228: up: 1: l = 2 n = 1 2: l = 2 n = 2 3: l = 2 n = 3 4: l = 2 n = 4 5: l = 1 n = 5 stealth_deagle: up: 1: l = 2 n = 1 2: l = 2 n = 2 3: l = 4 n = 3 4: l = 1 n = 4 5: l = 1 n = 5 stealth_fiveseven: up: 1: l = 3 n = 1 2: l = 2 n = 2 3: l = 2 n = 3 4: l = 4 n = 4 5: l = 1 n = 5 stealth_usp: up: 1: l = 2 n = 1 2: l = 1 n = 2 3: l = 1 n = 5 4: l = 3 n = 4 5: l = 2 n = 3 stealth_glock18: up: 1: l = 5 n = 1 2: l = 2 n = 2 3: l = 2 n = 3 4: l = 1 n = 4
100000 times.
I did some benchmarks and apparently it takes 7 seconds to read the file 100000 times and 28 seconds to organize the table.
JSON's output is 562 symbols and mine is 173 symbols, but it only takes JSON 10 seconds to decode all that.
Edit: Welp, this was an interesting test, and I'll stick to JSON, because I realized that I can do the same with JSON, but much faster.
Did you try any of the other glon replacements that people here on facepunch have made? Like von http://www.facepunch.com/showthread.php?t=1194008
Yeah, but I forgot what it was called. :X
Thanks for that though.
On another note, I think I'm gonna use this thing I made to encode on the server, send it to the client, and decode it there in order to network less stuff. (726 bytes vs 173)
I still use this. It's based on garry's keyvaluestotable and tabletokeyvalues:
function Deserialize(sIn) SRL = nil RunString(sIn) return SRL end local allowedtypes = {} allowedtypes["string"] = true allowedtypes["number"] = true allowedtypes["table"] = true allowedtypes["Vector"] = true allowedtypes["Angle"] = true allowedtypes["boolean"] = true local function MakeTable(tab, done) local str = "" local done = done or {} local sequential = table.IsSequential(tab) for key, value in pairs(tab) do local keytype = type(key) local valuetype = type(value) if allowedtypes[keytype] and allowedtypes[valuetype] then if sequential then key = "" else if keytype == "number" or keytype == "boolean" then key ="["..tostring(key).."]=" else key = "["..string.format("%q", tostring(key)).."]=" end end if valuetype == "table" and not done[value] then done[value] = true if type(value._serialize) == "function" then str = str..key..value:_serialize().."," else str = str..key.."{"..MakeTable(value, done).."}," end else if valuetype == "string" then value = string.format("%q", value) elseif valuetype == "Vector" then value = "Vector("..value.x..","..value.y..","..value.z..")" elseif valuetype == "Angle" then value = "Angle("..value.pitch..","..value.yaw..","..value.roll..")" else value = tostring(value) end str = str .. key .. value .. "," end end end if string.sub(str, -1) == "," then return string.sub(str, 1, #str - 1) else return str end end function Serialize(tIn, bRaw) if bRaw then return "{"..MakeTable(tIn).."}" end return "SRL={"..MakeTable(tIn).."}" end
I just tried making something to parse what you put up for shits and giggles. The file reading really kills me, took me around 23 seconds to read the file 100,000 times.
Without reading the file though, it only takes around 2 seconds to parse it 100,000 times.
local input = [[stealth_p228=1:2,2:2,3:2,4:2,5:1stealth_deagle=1:2,2:2,3:4,4:1,5:1 stealth_fiveseven=1:3,2:2,3:2,4:4,5:1 stealth_glock18=1:5,2:2,3:2,4:1 stealth_usp=1:2,2:1,5:1,4:3,3:2]] local function parse( input ) local out = {} for name, data in input:gmatch( "(.-)=([^\n]+)" ) do out[ name ] = { up = {} } local index = 1 for n, l in data:gmatch( "(.-):([^,]+),?" ) do out[ name ][ "up" ][ index ] = { l = l, n = n } index = index + 1 end end return out end local starttime = SysTime() for i=1, 100000 do parse( input ) end local endtime = SysTime() print( "COMPLETED!", endtime - starttime ) print( "Output:" ) PrintTable( parse( input ) )
![]()