What Are You Working On? -- October 2012

You have to give light_environment a targetname so it doesn’t get removed by the entity system. You can then do this on it

ent:Fire(“SetPattern”, math.char(num)) it’s from 1-127

You can also grab the entity in the key value gamemode hook and do it there, but clients need to do a fullupdate for the light to change. Spawning dynamic lights will also update the block you spawn it on. That method works somewhat OK if the time is synced to realtime since players usually reconnect or crash (unfortunately) in time for the light to update. It seems like when it’s not given a target name it doesn’t network to clients properly.

From the looks of it, it’s just simply modifying the world’s lightmap visibility, which usually looks much better than post processing.

Actually it ranges from 97 to 122, a to z in ascii decimal.

Yes you can.

[editline]31st October 2012[/editline]

Are we able to force this to happen? Console command? Something fiddly with sourcenet? Clientside module?

That’s what i thought it did too until i tested it on some other maps. anything below ~70 or above ~120 might not show visible results. It seems to depend on the light settings.

If you name the light_environment, it creates its own lighting style which is used for each lightmap lit by the light_environment
There are some refreshing issues when you change the light style of it though, its probable that the brushes arent getting added to the refresh list properly
But all that is in the Quake derived part of the engine code, its really a lost cause fixing the bugs with the weird flickering when dicking around with the light_environment

[editline]31st October 2012[/editline]

also random info: m is the normal light level, z is double and a is none

[editline]31st October 2012[/editline]

you can actually go below a and negative lighting occurs, it only really shows on props though

I think cl_fullupdate might do it, but requires cheats to be on (gm_cvar?) and it might break stuff.

I have no idea if sourcenet could do it though.

From fishing around it looks like the cl_fullupdate command, but it’s flagged as a cheat.

edit: ninja

I’m writing a custom bullet system because i can’t figure out how to make default bullets not draw decals on players.

So far it’s working perfectly except i can’t figure out the default effects that play when you shoot a certain surface. Any ideas?

[lua]
SWEP.MatDecals = {}
SWEP.MatDecals[ MAT_PLASTIC ] = “Impact.Concrete”
SWEP.MatDecals[ MAT_CONCRETE ] = “Impact.Concrete”
SWEP.MatDecals[ MAT_COMPUTER ] = “Impact.Concrete”
SWEP.MatDecals[ MAT_TILE ] = “Impact.Concrete”
SWEP.MatDecals[ MAT_METAL ] = “Impact.Metal”
SWEP.MatDecals[ MAT_GRATE ] = “Impact.Metal”
SWEP.MatDecals[ MAT_VENT ] = “Impact.Metal”
SWEP.MatDecals[ MAT_DIRT ] = “Impact.Concrete”
SWEP.MatDecals[ MAT_SAND ] = “Impact.Concrete”
SWEP.MatDecals[ MAT_SLOSH ] = “Impact.Concrete”
SWEP.MatDecals[ MAT_GLASS ] = “Impact.Glass”
SWEP.MatDecals[ MAT_WOOD ] = “Impact.Wood”

SWEP.MatSounds = {}
SWEP.MatSounds[ MAT_PLASTIC ] = Sound( “Plastic_Box.BulletImpact” )
SWEP.MatSounds[ MAT_CONCRETE ] = Sound( “Concrete.BulletImpact” )
SWEP.MatSounds[ MAT_COMPUTER ] = Sound( “Computer.BulletImpact” )
SWEP.MatSounds[ MAT_TILE ] = Sound( “Tile.BulletImpact” )
SWEP.MatSounds[ MAT_METAL ] = Sound( “SolidMetal.BulletImpact” )
SWEP.MatSounds[ MAT_GRATE ] = Sound( “MetalGrate.BulletImpact” )
SWEP.MatSounds[ MAT_VENT ] = Sound( “SolidMetal.BulletImpact” )
SWEP.MatSounds[ MAT_DIRT ] = Sound( “Dirt.BulletImpact” )
SWEP.MatSounds[ MAT_SAND ] = Sound( “Dirt.BulletImpact” )
SWEP.MatSounds[ MAT_SLOSH ] = Sound( “Flesh.BulletImpact” )
SWEP.MatSounds[ MAT_GLASS ] = Sound( “Glass.BulletImpact” )
SWEP.MatSounds[ MAT_WOOD ] = Sound( “Wood.BulletImpact” )

SWEP.MatEffects = {}
SWEP.MatEffects[ MAT_PLASTIC ] = “impact_concrete” // impact_x doesn’t work
SWEP.MatEffects[ MAT_CONCRETE ] = “impact_concrete”
SWEP.MatEffects[ MAT_COMPUTER ] = “Sparks” // this works
SWEP.MatEffects[ MAT_TILE ] = “impact_concrete”
SWEP.MatEffects[ MAT_METAL ] = “impact_metal”
SWEP.MatEffects[ MAT_GRATE ] = “impact_metal”
SWEP.MatEffects[ MAT_VENT ] = “impact_metal”
SWEP.MatEffects[ MAT_DIRT ] = “impact_dirt”
SWEP.MatEffects[ MAT_SAND ] = “impact_dirt”
SWEP.MatEffects[ MAT_SLOSH ] = “impact_dirt”
SWEP.MatEffects[ MAT_GLASS ] = “GlassImpact” // this works
SWEP.MatEffects[ MAT_WOOD ] = “impact_wood”

function SWEP:CreateBullets( scale, dmg, num )

//if CLIENT then return end

for i=1, num do

	local rand = VectorRand() * scale

	local dir = self.Owner:GetAimVector() + rand
	
	local trace = {}
	trace.start = self.Owner:GetShootPos()
	trace.endpos = trace.start + dir * 9000
	trace.filter = { self.Owner, self.Weapon }
	trace.mask = MASK_SHOT
	
	local tr = util.TraceLine( trace )
	
	local dmginfo = DamageInfo()
	dmginfo:SetAttacker( self.Owner )
	dmginfo:SetInflictor( self.Weapon )
	dmginfo:SetDamageType( DMG_BULLET )
	dmginfo:SetDamage( dmg )
	
	if IsValid( tr.Entity ) and not tr.HitWorld then
	
		if SERVER then
	
			tr.Entity:TakeDamageInfo( dmginfo )
			
		end
		
		if tr.Entity:IsPlayer() then
		
			GAMEMODE:PlayerTraceAttack( tr.Entity, dmginfo, dir, tr ) 
		
		else
		
			self.Weapon:BulletEffects( tr.MatType, tr.HitPos, tr.HitNormal )
			
			if SERVER then
			
				local phys = tr.Entity:GetPhysicsObject()
				
				if IsValid( phys ) then
				
					phys:ApplyForceCenter( dir * ( ( dmg * 100 ) ) )
				
				end
			
			end
		
		end
	
	else
	
		self.Weapon:BulletEffects( tr.MatType, tr.HitPos, tr.HitNormal )
	
	end
	
end

end

function SWEP:BulletEffects( mat, pos, norm )

if self.MatDecals[ mat ] then
		
	util.Decal( self.MatDecals[ mat ], pos + norm, pos - norm )
			
	sound.Play( self.MatSounds[ mat ], pos, 75, math.random( 90, 110 ), 0.8 )
			
	local eff = self.MatEffects[ mat ]
			
	local ed = EffectData()
	ed:SetOrigin( pos + norm )
	ed:SetStart( pos + norm )
	ed:SetNormal( norm )
	ed:SetMagnitude( 1 )
	ed:SetScale( 1 )
	util.Effect( ( eff or "Sparks" ), ed )	
		
end

end[/lua]

This is some code from my Toybox minigun that you’ll probably find relevant:

[lua]
local MatSurfacePropTranslate = {
[MAT_ANTLION] = util.GetSurfaceIndex(“antlion”),
[MAT_BLOODYFLESH] = util.GetSurfaceIndex(“bloodyflesh”),
[MAT_CONCRETE] = util.GetSurfaceIndex(“concrete”),
[MAT_DIRT] = util.GetSurfaceIndex(“dirt”),
[MAT_FLESH] = util.GetSurfaceIndex(“flesh”),
[MAT_GRATE] = util.GetSurfaceIndex(“metalgrate”),
[MAT_ALIENFLESH] = util.GetSurfaceIndex(“alienflesh”),
[MAT_CLIP] = util.GetSurfaceIndex(“player_control_clip”),
[MAT_PLASTIC] = util.GetSurfaceIndex(“plastic”),
[MAT_METAL] = util.GetSurfaceIndex(“metal”),
[MAT_SAND] = util.GetSurfaceIndex(“sand”),
[MAT_FOLIAGE] = util.GetSurfaceIndex(“foliage”),
[MAT_COMPUTER] = util.GetSurfaceIndex(“computer”),
[MAT_SLOSH] = util.GetSurfaceIndex(“water”),
[MAT_TILE] = util.GetSurfaceIndex(“tile”),
[MAT_VENT] = util.GetSurfaceIndex(“metalvent”),
[MAT_WOOD] = util.GetSurfaceIndex(“wood”),
[MAT_GLASS] = util.GetSurfaceIndex(“glass”)
}

    function SWEP:DoImpactEffect(tr, dmgtype)
        local edata = EffectData();
        edata:SetOrigin(tr.HitPos);
        edata:SetNormal(tr.HitNormal);
        edata:SetHitBox(tr.HitBox);
        edata:SetEntity(tr.Entity);
        edata:SetDamageType(dmgtype);        
        edata:SetStart(tr.StartPos);
        edata:SetSurfaceProp(MatSurfacePropTranslate[tr.MatType]);
        util.Effect("ImpactGunship", edata); --Can also be "Impact", probably others as well. These effects differ visually.
        return true;
    end

[/lua]

You can probably use the normal bullet system if you override SWEP:DoImpactEffect and just prevent the creation of an effect if the hit entity was a player.

[editline]31st October 2012[/editline]

Actually, you probably don’t even need to do any of that, just return true in SWEP:DoImpactEffect if the hit entity was a player. Otherwise, return false for the default impact effects.

Oh i had no idea that hook existed. Still, i need to override more than the effect, i need to make it not draw decals which is impossible from what i’ve seen. Bullets will always draw decals on whatever they hit which is the main issue.

e: Damn this looks just like normal bullets now. Thanks.

All i have to do is make water splash properly when i shoot it now.

-SNIP

Wrong thread, fuck

Experimenting with better slider controls. This one works like the scrubbing on an iphone. You can move the mouse up/down to zoom in and out, left and right to change the value. It’s a lot more accurate (and fun) than the little notched bar.

[hd]http://www.youtube.com/watch?v=y0WCi7vMfZ0[/hd]

An interesting idea…

Is there any chance of gui.OpenURL or an alternative coming back?



local PANEL={}

function PANEL:Init()
	self:SetVisible(false)
	self:SetSize(ScrW()*0.9,ScrH()*0.8)
	self:Center()
	self:SetTitle( "Web Browser" )
	self:SetDeleteOnClose( false )
	self:ShowCloseButton( true )
	self:SetDraggable( true )
	self:SetSizable( true )
	
	local top = vgui.Create( "EditablePanel", self )
		self.top=top
		top:Dock(TOP)
		top:SetTall(24)
		
	local btn = vgui.Create("DButton",self.top)
		btn:SetText("Back")
		btn:SizeToContents()
		btn:SetWide(btn:GetWide()+8)
		btn:Dock(LEFT)
		function btn.DoClick()
			self.browser:RunJavascript[[history.back();]]
		end
	local btn = vgui.Create("DButton",self.top)
		btn:SetText("Forward")
		btn:SizeToContents()
		btn:SetWide(btn:GetWide()+8)
		btn:Dock(LEFT)
		function btn.DoClick()
			self.browser:RunJavascript[[history.forward();]]
		end
	local btn = vgui.Create("DButton",self.top)
		btn:SetText("Refresh")
		btn:SizeToContents()
		btn:SetWide(btn:GetWide()+8)
		btn:Dock(LEFT)
		function btn.DoClick()
			self.browser:RunJavascript[[location.reload(true);]]
		end
		btn.Paint=function(btn,w,h) 
			DButton.Paint(btn,w,h)
			if self.loaded and self.browser:IsLoading() then
				self.loaded=false
			end
			if self.loaded then
				surface.SetDrawColor(100,240,50,200)
				surface.DrawRect(1,1,w-2,h-2)				
			end
			if not self.browser:IsLoading() then return end
			surface.SetDrawColor(240+math.sin(RealTime()*10)*15,100,50,200)
			surface.DrawRect(1,1,w-2,h-2)			
		end
		
	local entry = vgui.Create( "DTextEntry", top )
		self.entry=entry
		entry:Dock(FILL)
		entry:SetTall(  24 )
		
		function entry.OnEnter(entry)
			local val=entry:GetText()
			local js,txt = val:match("javascript:(.+)")
			if js and txt then
				self.browser:QueueJavascript(txt)
				return
			end
			self:OpenURL(val)
			
		end
		/*entry.Paint=function(entry,w,h)
			DTextEntry.Paint(entry,w,h)
			if self.browser:IsLoading() then
				draw.RoundedBox(h*0.5,w-h,0,h,h,Color(200,150,0,255))
			end
		end*/

		
	local browser = vgui.Create( "DHTML", self )
		self.browser=browser
		browser:Dock(FILL)
	browser.Paint=function() end
	browser.OpeningURL=print
	browser.FinishedURL=print
	browser:AddFunction( "gmod", "LoadedURL", function(url,title) self:LoadedURL(url,title) end )
	browser:AddFunction( "gmod", "dbg", function(...) Msg"[Browser] " print(...) end )
	browser:AddFunction( "gmod", "status", function(txt) self:StatusChanged(txt) end )
	browser.ActionSignal=function(...) Msg"[BrowserACT] " print(...)  end
	browser.OnKeyCodePressed=function(browser,code) 
		if code==96 then
			self.browser:RunJavascript[[location.reload(true);]]
			return
		end
		--print("BROWSERKEY",code)
	end
	
	local status = vgui.Create( "DLabel", self )
		self.status=status
		status:SetText""
		status:Dock(BOTTOM)
end

function PANEL:StatusChanged(txt)
	if self.statustxt~=txt then
		self.statustxt=txt
		self.status:SetText(txt or "")
	end
end

function PANEL:LoadedURL(url,title)
	if self.entry:HasFocus() then return end
	self.entry:SetText(url)
	self.loaded=true
	self:SetTitle(title and title!="" and title or "Web browser")
end
function PANEL:OpenURL(url)
	self.browser:OpenURL(url)
	self.entry:SetText(url)
end

function PANEL:Think(w,h)
	self.BaseClass.Think(self,w,h)
	if input.IsKeyDown(KEY_ESCAPE) then self:Close() end
	
	/*if self.browser:IsLoading() then
		self.browser:RunJavascript[[gmod.LoadedURL(document.location.href);]]
	end*/
	
	if not self.wasloading and self.browser:IsLoading() then
		self.wasloading=true
		--print"Loading..."
	end
	if self.wasloading and not self.browser:IsLoading() then
		self.wasloading=false
		--print("WAS LOADING")
		self.browser:QueueJavascript[[gmod.LoadedURL(document.location.href,document.title); gmod.status(""); ]]
		self.browser:QueueJavascript[[function alert(str) { console.log("Alert: "+str); }]]
		self.browser:QueueJavascript[[
			function getLink() {
				gmod.status(this.href || "-");
			}
			function clickLink() {
				if (this.href) {
					gmod.LoadedURL(this.href,"Loading...");
				}
				gmod.status("Loading...");
			}			
			var links = document.getElementsByTagName("a");
			for (i = 0; i < links.length; i++) {
				links*.addEventListener('mouseover',getLink,false)
				links*.addEventListener('click',clickLink,false)
			}

		]]
		--self.browser:QueueJavascript[[window.onclick = function( e ) { gmod.dbg("onclick"); }]]
		--self.browser:QueueJavascript[[window.onunload = function( e ) { gmod.dbg("onunload"); }]]
		--self.browser:QueueJavascript[[window.onbeforeunload = function( e ) { gmod.dbg("onbeforeunload"); }]]

	end	
	
end


function PANEL:Show()
	if not self:IsVisible() then
		self:SetVisible(true)
		self:MakePopup()
		self:SetKeyboardInputEnabled( true )
		self:SetMouseInputEnabled( true )
	end
	if ValidPanel(self.browser) then
		self.browser:RequestFocus()
	end
	--hook.Run("OnContextMenuOpen")
end


function PANEL:Close()
	self:SetVisible(false)
	--hook.Run("OnContextMenuClose")
end

local Cwebbrowser_panel = vgui.RegisterTable(PANEL,"DFrame")


local webbrowser_panel

function HidePanel()

	webbrowser_panel:Close()

end

local function ShowPanel(url)

	if not ValidPanel(webbrowser_panel) then
		webbrowser_panel=vgui.CreateFromTable(Cwebbrowser_panel)
		_G.p=webbrowser_panel
	end
	
	webbrowser_panel:Show()
	if url and url!="" then
		webbrowser_panel:OpenURL(url)
	end
	
end
function gui.OpenURL(url)
	ShowPanel(url)
end

concommand.Add( "webbrowser", function(a,b,c) local url=c[1] ShowPanel(url) end)

Ghetto webbrowser. Coded it half an hour ago, half asleep, half dead. Hope it’s use for someone.

The precision thing about sliders have always annoyed me a bit.
Want to go from value 0.2 to 0.25 but the smallest step (because of mouse DPI and sensitivity) is going from 0.2 to 0.5.
This solution solves that problem nicely. I know writing the exact values you want manually on the slider bars
isn’t much to ask but I would rather use your solution.

[lua]local surfaceType = Material( tr.HitTexture ):GetString("$surfaceprop") or “default_silent”

if IsValid( tr.Entity ) then
local phys = tr.Entity:GetPhysicsObject()
if IsValid( phys ) then
surfaceType = phys:GetMaterial()
end
end

local e = EffectData()
e:SetOrigin( tr.HitPos )
e:SetStart( tr.StartPos )
e:SetSurfaceProp( util.GetSurfaceIndex( surfaceType ) )
e:SetDamageType( DMG_BULLET )
e:SetHitBox( tr.HitBox )
if CLIENT then
e:SetEntity( tr.Entity )
else
e:SetEntIndex( tr.Entity:EntIndex() )
end
if SERVER then
SuppressHostEvents( bullet.owner )
end
util.Effect( “Impact”, e )
if SERVER then
SuppressHostEvents( NULL )
end[/lua]

How I did it for my bullet drop shit, the only issue it doesn’t work on displacements.

Not really Lua but generally interesting:

I added this little script to the wiki which converts the page name to a bunch of separated links:



(function(){
	var heading = document.getElementById("firstHeading");
	var path = heading.innerHTML;
	var splits = path.split("/");
	if(splits.length == 1)
		return;
	var newInnerHTML = splits.pop();

	var initLength = splits.length;

	for(var i = initLength;0<i;i--) {
		newInnerHTML = "<a href=\"/page/"+splits.join("/")+"\">"+splits[i-1]+"</a>" + "/" + newInnerHTML;
		splits.pop();
	}
	heading.innerHTML = newInnerHTML;
})();


https://fox.gy/dl0sijXblB.png

http://4stor.com/storage/new.png
November
http://forum.facepunch.com/showthread.php?t=1222478&p=38269772

Your early:

http://puu.sh/1l5Br