GMod - What are you working on? January 2015 (#41)
781 replies, posted
[QUOTE=StonedPenguin;46937714]autocomplete[/QUOTE]
Does that work with quotes?
[QUOTE=Robotboy655;46934257]So, I have tried to add fancy effects to my weather thing...
[t]http://i.imgur.com/xBINKuD.jpg[/t]
[/QUOTE]
I really like what you did with that 3d2d vehicle speed :)
[QUOTE=StonedPenguin;46937714]Just added autocomplete to my adminmod.
[t]http://p.sup.sx/i/1421311676.gif[/t]
[t]http://p.sup.sx/i/1421311637.gif[/t][/QUOTE]
Autocomplete is a sorely underused feature. What's worse is when developers skip autocomplete AND they neglect the help text option.
Always use that fourth argument in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/concommand/Add]concommand.Add[/url].
[QUOTE=StonedPenguin;46937714]Just added autocomplete to my adminmod.
[t]http://p.sup.sx/i/1421311676.gif[/t]
[t]http://p.sup.sx/i/1421311637.gif[/t][/QUOTE]
I always tried to make this work, could you publish an example ?
[QUOTE=bobbleheadbob;46939013]Autocomplete is a sorely underused feature. What's worse is when developers skip autocomplete AND they neglect the help text option.
Always use that fourth argument in [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/concommand/Add]concommand.Add[/url].[/QUOTE]
Since we're on the topic of auto-fill ( a very useful but underused system )... Here's what I'm working on:
It is commonly misunderstood how to properly integrate it despite wiki having a good example. On top of that, if you define a console command on the server and want autocomplete you need to have the console command defined on the client and network it to the server to execute it on the server ( which is why I added that feature to my net system: [url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/shared/classes/networking/cl_networking.lua?at=master[/url] first function; and I'll be adding helper functions to easily add it )
[code]networking:AddConCommand( "dev_spawnent", function( _cmd, _input )
// Set up out list, and process the input; it needs to be trimmed because the space ( which separates args ) isn't excluded...
_input = ( !_input || _input == "" ) && "" || string.Trim( string.lower( _input ) );
local _list = concommand.GetAutofillEntityList( _cmd, _input, _list )
return {
_cmd .. " <Entity ClassName>"; // This one is to show the player what is expected
unpack( _list ); // And this shows data based on what the user is typing
};
end, "[DEV] Spawns an entity, x, ( 5 feet + object size ) in front of the player." );
[/code]
[code]//
// This will be changed into a full fledged autofill system; this particular partial will be in charge of
// replacing <entity> or whatever in the template text.
//
function concommand.GetAutofillEntityList( _cmd, _input )
// Helper function to avoid needing to repeat this code over and over... Pass by reference, we're modifying _list directly.
local function ProcessEntityList( _cmd, _input, _data, _list )
for k, v in pairs( _data ) do
local _bContains = !_input || _input == "" || string.StartWith( string.lower( k ), _input );
local _blacklisted = ( BLACKLISTED_ENTITIES[ string.lower( k ) ] || BLACKLISTED_WEAPONS[ string.lower( k ) ] );
if ( _bContains && !_blacklisted ) then
table.insert( _list, _cmd .. " " .. k );
end
end
return _list;
end
// All of the _list = aren't needed because of pass by ref, the helper-function is modifying the actual list
// so it isn't needed; but I plan on recoding it to make it much more robust so I'm leaving it...
local _list = { };
_list = ProcessEntityList( _cmd, _input, list.Get( "SpawnableEntities" ), _list );
_list = ProcessEntityList( _cmd, _input, list.Get( "NPC" ), _list );
_list = ProcessEntityList( _cmd, _input, list.Get( "Weapon" ), _list );
_list = ProcessEntityList( _cmd, _input, list.Get( "Vehicles" ), _list );
return _list;
end[/code]
So I'm working on making it easy to add autofill so you can set up an autofill by specifying arguments ( like "<cmd> <ent_class>", "<cmd> <ent_id>", "<cmd> <player_steamid>", "<cmd> <player_name>" and see if I can add sub-options such as <player_steamid:display name> so a name will be displayed but the steamid will be used when selected )..
[editline]15th January 2015[/editline]
[QUOTE=ExtReMLapin;46939089]I always tried to make this work, could you publish an example ?[/QUOTE]
The wiki has a great tutorial, the function I provided to generate a list will also work ( just create the blacklist table, etc in the form: blacklists = { weapon = true, ent_class = true }; etc... )
[url]http://wiki.garrysmod.com/page/Autocomplete_Tutorial[/url]
[QUOTE=Acecool;46939090]
[code]
return {
_cmd .. " <Entity ClassName>";
unpack( _list );
};
[/code]
[/QUOTE]
Why would you even... Just table.insert at the first position.
The function returns a table while the autocomplete system requires a table, not tables in tables.
This was just the first "proof" I wrote to start developing the automatic auto-fill system so there will be changes to optimize it ( and when it is done it'll require an argument which sets the layout of the auto-fill meaning I can just return _list; because the list will automatically insert the layout string as the first entry and process any replacements ).
I could define the table there and then using Lua pass-by-reference system to modify the table directly without needing to return anything which would also allow me to return _list but that just means more code the end-developer will need to write for the system to work. It'll be more of a 1 line thing when I'm done such as: [code]networking:AddConCommand( "ban", "<player_steamid:display name> <time:abs, duration>" );[/code] which would then add a clientside console command "ban" which networks to the server ( meaning the console command exists on the server and can have all of the checks but have a clientside autocomplete while the security checking remains on the server ) with automatic display of the helper string and player names which get replaced with steamid then number for ban time..
[QUOTE=Acecool;46940023]The function returns a table while the autocomplete system requires a table, not tables in tables.
This was just the first "proof" I wrote to start developing the automatic auto-fill system so there will be changes to optimize it ( and when it is done it'll require an argument which sets the layout of the auto-fill meaning I can just return _list; because the list will automatically insert the layout string as the first entry and process any replacements ).
I could define the table there and then using Lua pass-by-reference system to modify the table directly without needing to return anything which would also allow me to return _list but that just means more code the end-developer will need to write for the system to work. It'll be more of a 1 line thing when I'm done such as: [code]networking:AddConCommand( "ban", "<player_steamid:display name> <time:abs, duration>" );[/code] which would then add a clientside console command "ban" which networks to the server ( meaning the console command exists on the server and can have all of the checks but have a clientside autocomplete while the security checking remains on the server ) with automatic display of the helper string and player names which get replaced with steamid then number for ban time..[/QUOTE]
[img]http://i.imgur.com/NUruZtb.png[/img]
Inserting at the first position is as bad as what the current code does. It inserts at the first position and shifts all other values over by 1 ( n times ) whereas the current one is n for the current table, ie n-1...
It'll be revised and optimized so that unpack won't be needed in the future and the helper line will be the first entry before the others are added ( instead of the dev needing to create the list before the call to the helper/replacer function, etc... )
[QUOTE=Acecool;46940148]Inserting at the first position is as bad as what the current code does. It inserts at the first position and shifts all other values over by 1 ( n times ) whereas the current one is n for the current table, ie n-1...
It'll be revised and optimized so that unpack won't be needed in the future and the helper line will be the first entry before the others are added ( instead of the dev needing to create the list before the call to the helper/replacer function, etc... )[/QUOTE]
This code is ran once at startup. Optimization at this level means nothing.
[QUOTE=AirBlack;46938551]Does that work with quotes?[/QUOTE]
Yes.
[QUOTE=ExtReMLapin;46939089]I always tried to make this work, could you publish an example ?[/QUOTE]
There's a pretty basic example on the wiki that should give an idea how it works. [url]http://wiki.garrysmod.com/page/Autocomplete_Tutorial[/url]
[QUOTE=bobbleheadbob;46940412]This code is ran once at startup. Optimization at this level means nothing.[/QUOTE]
Actually, results change as the player types for auto-complete to narrow down the list; it isn't ran once...
[QUOTE=Acecool;46940832]Actually, results change as the player types for auto-complete to narrow down the list; it isn't ran once...[/QUOTE]
But registering the autocomplete is ran but once, and that is where the dispute is.
[img]http://i.imgur.com/uXOuxyX.gif[/img]
I finally figured out a perfect circle drawing function with surface.DrawPoly :v:
[QUOTE=Robotboy655;46940966][img]http://i.imgur.com/uXOuxyX.gif[/img]
I finally figured out a perfect circle drawing function with surface.DrawPoly :v:[/QUOTE]
Trigonometry!
[QUOTE=bobbleheadbob;46940974]Trigonometry![/QUOTE]
Who would've thought that they teach kids in schools things that can actually be useful.
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/poly/simplified_circles_with_poly.lua.html[/url]
Use draw.NoTexture( ) before drawing the poly to allow alpha to work, otherwise it'll always be translucent.
Textures!
[img]http://i.imgur.com/HS5HpSv.gif[/img]
Acecool, your method sucks a bit, as in, you set UVs, but they don't do jack shit:
[img]http://i.imgur.com/VvOq0mj.png[/img]
I'd think you'd at least make your lua examples working out of the box, if you are going to teach anybody anything.
You're right, that example doesn't have the uvs set properly... It's an old tutorial though so I haven't updated it yet with the new code but I'll do that in a bit ( I may phase it out though and extend the creating shapes tut when I finish the full poly meta-table ).
I do have an option for the UV to spiral with the circle on one of the releases vs just stay flat )...
Which will be in this soon: [url]https://bitbucket.org/Acecool/acecooldev_base/src/master/gamemode/client/classes/class_poly.lua?at=master[/url]
[code]
//
// Creates a circle
//
function poly:MakeCircle( _x, _y, _r, _points, _textureScale )
// U is how many times the texture should repeat along the X
local _u = ( _x + _r * 1 ) - _x;
local _u = 1;
// V is how many times the texture should repeat along the Y
local _v = ( _y + _r * 1 ) - _y;
//
local _textureScale = _textureScale || 0.099;
local _slices = ( 2 * math.pi ) / _points;
local _poly = { };
for i = 0, _points - 1 do
local _angle = ( _slices * i ) % _points;
local x = _x + _r * math.cos( _angle );
local y = _y + _r * math.sin( _angle );
// i / _points
// i * _angle / _points
table.insert( _poly, { x = x; y = y; u = _u; v = ( ( i * _angle / _points ) * _textureScale ) } );
end
return _poly;
end
[/code]
There's the one that spirals ( and can be changed to go from straight to spiral )...
Am I missing something, or is this intentional? Initializing _u twice?
[IMG]http://puu.sh/ez7uR/c59f9c32ba.png[/IMG]
even better, he declares _v but he never actually uses it
[QUOTE=Robotboy655;46941015]Who would've thought that they teach kids in schools things that can actually be useful.[/QUOTE]
I'll take that back once I have to divide polynomials
I've added my version here:
[url]http://wiki.garrysmod.com/page/surface/DrawPoly[/url]
[t]http://cloud-4.steamusercontent.com/ugc/32983196119564859/ADE4322CBC145B2FB136A9B20083D0B6C450EF74/[/t]
Anyone guess what i've been working on?
In case it's not that obvious, a pay day gamemode for gmod.
Player model, unlocks and current character data will be displayed on the menu as a filler of empty space.
[QUOTE=AIX-Who;46941783][t]http://cloud-4.steamusercontent.com/ugc/32983196119564859/ADE4322CBC145B2FB136A9B20083D0B6C450EF74/[/t]
Anyone guess what i've been working on?
In case it's not that obvious, a pay day gamemode for gmod.
Player model, unlocks and current character data will be displayed on the menu as a filler of empty space.[/QUOTE]
I worked on something like that. You might be able to use some of my ideas. [url]https://github.com/wyozi/budgetday/[/url]
[QUOTE=Exho;46941628]I'll take that back once I have to divide polynomials[/QUOTE]
I actually had to divide polynomials while making [URL="https://github.com/Luabee/Luabee"]Luabee[/URL].
I don't remember why, or for what purpose, but I remember at some point while making that addon that I looked up and realized that holy fuck I'm actually using this again.
To join the circle bandwagon, there's one in wiremod here: [url]https://github.com/wiremod/wire/blob/master/lua/entities/gmod_wire_egp/lib/objects/circle.lua[/url] although I didn't make it. If I remember correctly, it was a guy named Sk8. His version supports ellipses as well, by allowing you to set width and height separately. Also supports rotation (useful if it's an ellipse).
EDIT: hnnngg why do some of you insist on using table.insert (to push items to the end of the table) 100 times per frame, instead of just t[#t+1] = v or better yet, t[i] = v. my inner optimization nazi commits suicide :suicide:
Eat your heart out WalkingZombie, making folders sucked ass but they are pretty much done! They still error occasionally, you can't rearrange stuff inside them yet (but you can move them out), and there is some wacky-ass behavior I need to fix with my special text entry (invisible DTextEntry with a DLabel on top, I made the caret myself). And thanks Neth for that sexy blur code!
[t]http://i.gyazo.com/0625c7200a1cee2038545ee4c2a6cff0.png[/t][t]http://i.gyazo.com/099f3bb046aba204a29f4f86ba530cee.png[/t]
Edit: Almost forgot, I had a huge concern with the limit of apps with the old system (4x5 I think) and I didn't know how to nicely implement pages. So now with folders the max amount of apps you can have is now 180 instead of 20, I think...
Why not use a DListView for the apps page ( smooth scrolling ), and "pages" for the home-page if they're different.
My issue was just that it would scroll down and I didnt want that for perfectionist reasons.
Sorry, you need to Log In to post a reply to this thread.