• What Are You Working On? Mesh Edition - August 2012
    650 replies, posted
[QUOTE=Banana Lord.;37331780][lua]local function formatNumber(n) if (!n) then return 0 end if n >= 1e14 then return tostring(n) end n = tostring(n) sep = sep or "," local dp = string.find(n, "%.") or #n+1 for i=dp-4, 1, -3 do n = n:sub(1, i) .. sep .. n:sub(i+1) end return n end[/lua] that's the one I'm talking about, I think it's by raBBish but I can't remember[/QUOTE] That one is cleaner and faster, so I'll probably use that one.
Since we're getting all comma-fied: Have some Kogitsune code! [lua] local function comma_value(amount) local formatted = amount while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end end return formatted end [/lua]
[QUOTE=Feihc;37334253]Since we're getting all comma-fied: Have some Kogitsune code! [lua] local function comma_value(amount) local formatted = amount while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1,%2') if (k==0) then break end end return formatted end [/lua][/QUOTE] We have competition, boys. [Img]http://puu.sh/XhlH[/Img]
I'm in! [lua] function _addCommasToStr(str) return str:reverse():gsub("(...)", "%1,"):gsub(",$", ""):reverse() end [/lua]
And the best entries have started pouring in! [lua] function commaify(number) error("todo") end [/lua]
[Img]http://puu.sh/XiWM[/Img] :v:
Knew it.
-snip-
[QUOTE=Wizard of Ass;37334983]I'm in! [lua] function _addCommasToStr(str) return str:reverse():gsub("(...)", "%1,"):gsub(",$", ""):reverse() end [/lua][/QUOTE] [code]Expected: -12,345,678.12345 Got: -12,345,678,.12,345[/code] Fast function but output leaves a little to be desired :v:
Still fast when fixed [lua] function _addCommasToStr(str) local _,_,str,dec = str:find("^(-?%d+)(%.*%d*)$") return str:reverse():gsub("(...)", "%1,"):gsub(",$", ""):reverse()..dec end [/lua]
[QUOTE=Kogitsune;37338920][code]Expected: -12,345,678.12345 Got: -12,345,678,.12,345[/code] Fast function but output leaves a little to be desired :v:[/QUOTE] Well, it wasn't designed to for floating point, just copy pasted that from my gamemode :v:
poop
[IMG]http://puu.sh/XADG.png[/IMG]
Do you guys just paint onto 2D3D's in front of the player? I never made one of those 3D huds. I imagine it'd be easier doing it with a model matrix and just painting 2D
And bleh I haven't posted anything amusing in ages, been so busy :( [t]http://4stor.com/images/sQ7v.png[/t] Configuration parser. (Thanks Wizzy for helping with the pattern shit<3)
[QUOTE=Spencer Sharkey;37353252]And bleh I haven't posted anything amusing in ages, been so busy :( *img* Configuration parser. (Thanks Wizzy for helping with the pattern shit<3)[/QUOTE] Why don't you have it detect if it's a number, boolean, or string, so you don't have to specify the type?
Because I want set config value types per variable. Okay now that that's done, time to go make a node-based permission/group system.
[QUOTE=Spencer Sharkey;37353410]Because I want set config value types per variable. Okay now that that's done, time to go make a node-based permission/group system.[/QUOTE] Well I made it for you anyway :D Use it if you want [code]local str = [[mysql_enable = true mysql_hostname = "localhost" mysql_port = 3306 #This_is_a_comment = "so it isn't parsed" mysql_username = "root" #This is also a comment mysql_password = "hurr durr" mysql_database = "enviso"]] local function OpenConfig() local ret = {} for key, value in string.gmatch( str, "([#%w_]+) *= *(.-)\n" ) do if string.sub( key, 1, 1 ) ~= "#" then local value, comment = string.match( value, "([^#]+)(.*)" ) if value == "true" or value == "false" then ret[key] = value == "true" elseif tonumber(value) then ret[key] = tonumber(value) else local STR = string.match( value, '%b""' ) if not STR then error( "Invalid config syntax" ) end ret[key] = string.sub( STR, 2, -2 ) end end end return ret end for k,v in pairs( OpenConfig( "hurr durr" ) ) do print("'"..k.."'","=","'"..tostring(v).."'",type(v)) end[/code] EDIT: Oh right, comments. One sec EDIT: Done EDIT: Output: [code]'mysql_username' = 'root' string 'mysql_port' = '3306' number 'mysql_enable' = 'true' boolean 'mysql_password' = 'hurr durr' string 'mysql_hostname' = 'localhost' string[/code]
Nothing people would find impressive, but it lives up to it's standard with Me. :D [video=youtube;qijLkne96xo]http://www.youtube.com/watch?v=qijLkne96xo&feature=youtu.be[/video] Video Still Uploading Credits go to Ollie for the Code. Drakehawke for helping me fix some minor stuff. Helba (Me) for the sound.
[QUOTE=walkmanguy;37355645]Nothing people would find impressive, but it lives up to it's standard with Me. :D [video=youtube;qijLkne96xo]http://www.youtube.com/watch?v=qijLkne96xo&feature=youtu.be[/video] Video Still Uploading Credits go to Ollie for the Code. Drakehawke for helping me fix some minor stuff. Helba (Me) for the sound.[/QUOTE] I'm not sure why this guy is getting boxes, he worked on something and finished (?) it. Even if he did need help at one point he still accomplished something...
[QUOTE=Banana Lord.;37357925]I'm not sure why this guy is getting boxes, he worked on something and finished (?) it. Even if he did need help at one point he still accomplished something...[/QUOTE] I don't want to be a dick or anything, but i coded the "mini-addon", he just gave me the sound. I also made the .vtf and .vmt
[HD]http://www.youtube.com/watch?v=U9guoDQ4KGI[/HD] Please ignore the z-fighting, the tool isn't done yet.
[QUOTE=Silverlan;37358322][HD]http://www.youtube.com/watch?v=U9guoDQ4KGI[/HD] Please ignore the z-fighting, the tool isn't done yet.[/QUOTE] Please excuse my while I pickup all these bricks i just shit
[QUOTE=Silverlan;37358322][HD]http://www.youtube.com/watch?v=U9guoDQ4KGI[/HD] Please ignore the z-fighting, the tool isn't done yet.[/QUOTE] My mind! You have to tell me how you managed to do that.
[QUOTE=vexx21322;37358384] You have to tell me how you managed to do that.[/QUOTE] I'm retrieving the brush information directly from the bsp-file. There's a downside to it though: I need to calculate every single brush in the map to be able to find out what brush a player has fired on. This only needs to be done once per session, but it takes about 20 seconds for a map like gm_construct. I'll try to improve it, but I don't think I can get it much faster.
i am in awe, that is amazing
theoretically you could just have a flat map and brushes inside of it, and then build your own map inside the game :O!
[QUOTE=Silverlan;37358521]I'm retrieving the brush information directly from the bsp-file. There's a downside to it though: I need to calculate every single brush in the map to be able to find out what brush a player has fired on. This only needs to be done once per session, but it takes about 20 seconds for a map like gm_construct. I'll try to improve it, but I don't think I can get it much faster.[/QUOTE] GM13's binary reading already being used for cool shit? And I guess the delay isn't something you really can do much about.
[QUOTE=Silverlan;37358521]I'm retrieving the brush information directly from the bsp-file. There's a downside to it though: I need to calculate every single brush in the map to be able to find out what brush a player has fired on. This only needs to be done once per session, but it takes about 20 seconds for a map like gm_construct. I'll try to improve it, but I don't think I can get it much faster.[/QUOTE] Why is this needed at all? All the data is already read, what's stopping you from getting at it?
[QUOTE=laylay;37358855]Why is this needed at all? All the data is already read, what's stopping you from getting at it?[/QUOTE] Because the brushes are stored as planes in the bsp. You have to calculate the plane intersections to build the whole mesh, which is quite expensive if the mesh has a lot of sides. The planes are not enough to find an accurate trace intersection.
Sorry, you need to Log In to post a reply to this thread.