Subscribe
 Post #1
 27th April 2007
Syranide's Avatar
April 2007
453 Posts

Current version: 1.0.0, released on 2008-03-30, compatible with the GMOD update!
If SmartSnap does not work for you, get the latest version first! FPS drops when showing the grid has been FIXED!


●●●● Introduction ●●●●

This is a client-side tool for building contraptions with extreme precision, aligning objects for either aesthetic or functional perfection. To accomplish this task a grid is projected onto the object you are pointing at and by pressing the use-button your weapon will lock onto that point and allow you to place objects with pin-point accuracy. For all entities be them square, round or uneven this tool will bring you perfect precision. This is a remake of the classic AutoSnap with a multitude of improvements. We all loved AutoSnap, and since the development of it had almost come to a halt I decided it was time to bring it back to life, the code has been written from scratch.

If you have any feedback or ideas to improve this addon I would be very happy to hear them!

●●●● Model addons ●●●●

Get the latest model addons here, corrected model offsets are included in each separate addon.

PhoeniX-Storms: http://forums.facepunchstudios.com/s...d.php?t=488601
Primitive Mechanics: http://forums.facepunchstudios.com/s...d.php?t=507452
Tiled Building Blocks: http://forums.facepunchstudios.com/s....php?p=9284781

●●●● Changelog ●●●●

2008-03-30, v1.0.0 (important update):
● FPS drops when the grid is showing have been fixed, it is not directly caused by SmartSnap, but the use of SmartSnap increases per frame memory consumption and the garbage collector obviously handles this very poorly. Please give me some feedback on how this works out for you all.
● "default model offset" has been removed to improve consistency for model addons, it now hardcoded to 0.25 which appears to the default for the source models.
● Bumped to version 1 because it is about time now!

2008-03-30, v0.9.5 (useful update):
● Grid offset only affects the outer border of the grid now and does not scale the entire grids, provides better snapping for "building blocks".
● Per model offsets are now provided for each separate model addon instead, update your model addons! (links above)
● Added "click grid" mode, disables the grid until USE is clicked while looking at a prop, looking away from a prop disables the grid again.
● Fixed a very rare bug that causes SmartSnap errors (thanks kevkev)

2008-01-17, v0.9.4 (compatibility update):
● Using presets for settings instead (also fixes rare cases of the grid not showing)
● Should be fully compatible with the GMod update, complain here otherwise
(Your settings will be reset when updating to this version)

2007-12-23, v0.9.3 (minor update):
● Fixed per-model offsets, broke in last update
● Added default model offsets, should make corners useable on more models (option provided)
● Some minor optimizations
(SmartSnap can be installed on servers and will downloaded to clients automatically)

2007-11-28, v0.9.2 (compatibility update):
● Fixed errors that would appear when running the latest GMod10 beta
● New option to turn off the grid, leaving only the marker
● General optimizations and code improvements

2007-07-22, v0.9.1 (compatibility update):
● Fixed settings not appearing in the spawnmenu since the GMod10 update

2007-05-07, v0.9.0 (major update):
● Custom per-model offsets (more information below)
● New snap mode, perfect precision from "any" angle on any model, even rounded or uneven (more information below)
● New grid system, there are no longer gaps between the black and white lines, and the lines no longer go haywire when you are too close
● Easy access grid toggling, set "toggle delay" to enable, double-click the snap-key within that time to toggle the grid, console command "snaptogglegrid"
● Rewrote the square face picking routines
● Context mouse snapping is available again
● Thick center line for the grid (optional)
● New options (I'm open for more suggestions)
● And a lot of minor fixes everywhere

2007-04-27, v0.8.1 (major changes):
● There is now a "lock snap mode", that will keep the snap without holding a key by binding a key to the "snaplock" (idea by Vampired)
● Based on the previous there is now a "smart snap lock" that will activate after a short delay, off by default and adjustable delay (idea by Vampired)
● The snap button can now be assigned to another key by binding that key to "+snap", "snap_disableuse 1" to disable default snap key
● The settings are no longer lost when restarting the game

2007-04-25, v0.8.0 (initial release):
● The grid is black and white, visible on both light and dark objects
● The cursor indicates potentially bad angle with colors, red/yellow/green (new mode as of 0.9.0)
● The cursor is tilted to provide better visiblited
● The cursor turns turquoise in context mode if you are too far away and the margin of error will be noticeable (the cursor is imprecise)
● The aim now snaps completely to the grid, wobbling the mouse does not affect placement, also allows you to place objects from the other side of the map with pinpoint accuracy
● The snap does not release or shift when moving, it always sticks to the same snap point, you can even walk around the object while still attached to the same point
● The square grid works for all objects, regardless of the model
● The grid has been offset inwards slightly too minimize the common gap that was always present (for most square objects there is no gap now)
● The grid has been offset from the edges so that the outer lines of the grid are useable as well
● The objects' bounding box is made visible by blue markers on each corner
● The grid is selected by the aim/mouse and not the viewing angle, you can now point at any visible side and see the grid without moving
● The grid is smart, for smaller objects, less snap points will be available
● The snap point finding algorithm runs in constant time, meaning that regardless of number of snap points, it will always be as fast

●●●● Suggested improvements ●●●●

● Quickly accessible grid size settings (idea by AfTeRsHoCk)

●●●● Installation ●●●●

Simply unzip the archive into your garrysmod/addons-directory and it should be working, read the instructions on how to use it.

●●●● Instructions ●●●●

If you have used AutoSnap before, there should not be any problem to understand this either, although there are some major improvements that might make it feel different, especially the new ultra precise mouse snap. For the uninitiated, it is very simple to use this addon, simply install it, start a game, spawn a prop, bring up the toolgun, look at the prop and a grid should appear. If you press use (e), the mouse should snap to the point you look at, and will signal with colors how precise the placement will be. Options for this addon is located under "Spawnmenu/Options/Smartsnap Settings". If you have any questions, I will be more than happy to answer them!

●●●● The new snap mode ●●●●

As of v0.9.0, there is now a new technique in place for allowing perfectly placed objects that relies on the curvature of the object to position the mouse. It is now also possible to use the grid on round/uneven models, the grid will not fold around the model, but the snap will trace from the grid to the model to create a perfect snap.

As of this, the color of the cursor no longer indicates the angle, but the actual distance between the calculated snap and where the object would end up (the error). Green indicated almost perfect precision, yellow means very good placement and red means the view is obstructed or the error will be significant. Turquoise means that it cannot snap because the model does not occupy that snap point and purple indicates that the snap is obstructed or failing to correctly trace a line.

As this below image shows, some of you might think that the new SmartSnap is bugged or incorrect, but it is not, it's the new snapping that shows you where it actually ends up, this means that the grid will not always align to where the mouse aims as the actual bounding box of the object might be different. As seen above, I place 2 thrusters from two different angles on a round prop and they both end up perfectly horizontal.



Also, very few entities behave oddly when traced as such the trace fails and reverts to the "old snap mode", indicated by a purple cursor. What this means is that certain props reports bad values when traced for certain snap points, this is not caused by my code but is a flaw in HL2 I believe. However, in almost all cases you can fix this by simply rotating the entity a little and it should be able to trace properly.

●●●● Per-model grid offset ●●●●

As of v0.9.0, it is now possible to define individual grid offsets for each model, so that corners can be fully utilized and match the visual representation of the model with the position of the grid. A number of models (mostly PHX) has been predefined in the release with 0.01 precision.

To create custom grid offsets yourself, you will have to bind buttons for "snap_dev_gridoffset <distance>", where distance is the distance to offset the grid for each press, I recommend binding 0.1/0.01/-0.1/-0.01 if you want to create precise grid offsets. To offset the grid, simply look at a face of the prop, and press the button and that grid will be slightly offset inwards (+) or outwards (-) (by using snap_dev_alloffset, all faces of the object will be offset by the same amount). Personal recommendation is to set the material of the object to matte white before starting. You must point at the object and execute "snap_dev_saveoffset" for it to be saved when you disconnect!

●●●● Demonstration of v0.8.0 ●●●●

To show you how it looks and works I made an untalented video where I show off (in order):
● No gap between the grid and the object (barely visible blue marker)
● Place objects while snapped to the outer line of the grid
● Snap to the grid and walking around while snapped
● Cursor changing color at different angles (barely visible cursor)
● Grid visible on shiny white objects aswell
● Showing that the snap does not release when walking around or pushing the prop
● And the grand finale, placing a nailer with pinpoint accuracy from the other side of the map





Credits goes to Black Phoenix for help with some vector math equations, Robbis_1 as he is the author of Autosnap and Locklear (Leon_307) for being the original inspiration for Autosnap.
 Post #2
 27th April 2007
Finaldeath's Avatar
March 2007
1,362 Posts
Yes you fucking did it lua kinged.

Ps: sorry for my french :P
 Post #3
 27th April 2007
Leigon's Avatar
April 2007
8 Posts
Woh this is ausom, thanks finaly no more weard jumpy snapping :)
 Post #4
 27th April 2007
MaZz3's Avatar
March 2007
54 Posts
Really good job!
 Post #5
 27th April 2007
henrikb4's Avatar
June 2005
1,991 Posts
You got a download!
 Post #6
 27th April 2007
Metroid48's Avatar
February 2007
1,279 Posts
Nice, does seem really similar to autosnap. Is this client side, like autosnap?
 Post #7
 27th April 2007
sub-zero1234's Avatar
February 2006
95 Posts
thank you so much
 Post #8
 27th April 2007
Syranide's Avatar
April 2007
453 Posts
Thanks you all for the comments! ;)

Metroid48 posted:
Nice, does seem really similar to autosnap. Is this client side, like autosnap?
Yes, this is "autosnap", but I rewrote it from scratch and added all the improvements mentioned in the first topic. So you will feel very familiar, and it is 100% client side.
 Post #9
 27th April 2007
garry's Avatar
September 2001
9,914 Posts
This is pretty interesting..
 Post #10
 27th April 2007
Tatourmi's Avatar
October 2006
54 Posts
This is really useful for the contraptions :D
 Post #11
 27th April 2007
Bad HAL 9000's Avatar
January 2005
318 Posts
Great, was looking forward to this. :)
 Post #12
 27th April 2007
Razot's Avatar
April 2007
61 Posts
um... what does it do

(User was banned for this post (Reason: RCP (in post "Re: SmartSnap (snap the mouse to objects)" by garry)))
 Post #13
 27th April 2007
Syranide's Avatar
April 2007
453 Posts
Razot posted:
um... what does it do
Just like Autosnap, it allows you to "snap" the view to a grid, allowing you place thrusters/gates/whatever or weld/etc with perfect precision on most square objects. So it's a tool for building precisely aligned contraptions and groups of objects.
 Post #14
 27th April 2007
TheTiger's Avatar
November 2006
696 Posts
just similar with auto snap but better but anoying thing that some of grid goes inside prop but better corner grid's than in autosnap gold star for you
 Post #15
 27th April 2007
Phasy's Avatar
May 2005
250 Posts
It does not work.

It's in the addons folder, I installed it on both my server and on my client, yet there is no menu for it in options, and it doesn't seem to work at all.
 Post #16
 27th April 2007
Syranide's Avatar
April 2007
453 Posts
TheTiger posted:
just similar with auto snap but better but anoying thing that some of grid goes inside prop but better corner grid's than in autosnap gold star for you
Aha, that will be fixed in a coming version, it will then be possible to specify offsets for specific props, which allow it to align perfectly for all square props. Expect to see this any day.

I temporarily have a global inward offset for the grid at the moment because it allows for an overall smaller gaps.

Edit:

Phasy posted:
It does not work.

It's in the addons folder, I installed it on both my server and on my client, yet there is no menu for it in options, and it doesn't seem to work at all.
Oh sorry, this is most likely because you have to have a tool-weapon (e.g. nailer, thruster etc) in your hands for it to show! Very sorry that I forgot to mention this in the initial post, will fix it immediately.
 Post #17
 27th April 2007
Gold Member
conman420's Avatar
January 2007
4,644 Posts
THANK YOU! I was so annoyed by the bug in auto-snap where the corners where off the prop :( You are my saviour!

Was this built from scratch or did you just edit robbis's code?

Never mind about that bit I just read a post above.

Nice work!
 Post #18
 27th April 2007
Phasy's Avatar
May 2005
250 Posts
Syranide posted:
Oh sorry, this is most likely because you have to have a tool-weapon (e.g. nailer, thruster etc) in your hands for it to show! Very sorry that I forgot to mention this in the initial post, will fix it immediately.
Yeah, now that you mention it, that's probably it.

I don't think it works on vehicles, does it?

Edit:

By the way, if it only shows when your holding a tool weapon, does that mean it also only shows in the options menu when your holding a tool weapon?
 Post #19
 27th April 2007
Syranide's Avatar
April 2007
453 Posts
Phasy posted:
Yeah, now that you mention it, that's probably it.

I don't think it works on vehicles, does it?
Only works on props at the moment, but I will add an option for it to show up on everything in the next release, although, it might not align very well for most vehicles as they tend to have non-square forms, but it should be useable still if you just make sure to have a green cursor before placing.
 Post #20
 27th April 2007
Phasy's Avatar
May 2005
250 Posts
Yeah. Anyway, the option problem was my fault and it works now. Good work, have a gold star for the mod and the support.
 Post #21
 27th April 2007
Joel_Yeah's Avatar
July 2006
612 Posts
Syranide posted:
I made an untalented video where I show off
Fixed

Also, looks great, got my download :D

[spoiler]tl;dr... Looks great though [/spoiler]
 Post #22
 27th April 2007
Gold Member
conman420's Avatar
January 2007
4,644 Posts
You might want to increase the gap between the corner. On the cargo container you get the annoying corner bug!

Robbis_1 posted:
That's not bugged.. I added 4 sliders for each corner. The way it scales depends on the prop.
If you're so clever now, go ahead and make it better.
Robbis asked for it there didn't he?
 Post #23
 27th April 2007
Syranide's Avatar
April 2007
453 Posts
conman420 posted:
You might want to increase the gap between the corner. On the cargo container you get the annoying corner bug!
Will be fixed when I implement the per prop "offset" for the grid (should be very very soon), increasing the default grid edge offset would become problematic with thin props (which are already quite tight).

(And I will most likely specify such offsets in advance for most props, so you don't have to do every single one yourself)
 Post #24
 27th April 2007
NisseOwned's Avatar
July 2006
245 Posts
Oh snap!
Great, been wanting something like this for long :excited:
 Post #25
 27th April 2007
Gold Member
elevator13's Avatar
December 2006
3,986 Posts
I loved Robbis' autosnap, and I can't wait to try this out
 Post #26
 27th April 2007
AfTeRsHoCk's Avatar
May 2005
394 Posts
NisseOwned posted:
Oh snap!
...
Indeed.

One suggestion though, could you add a feature so that it allows you to change the settings of the snap-grid via something other than the settings menu? Like, maybe a second context panel or something equally (most likely) impossible and ridiculous.

It's just kind of a hassle to keep going back and forth between the STool menu and the settings menu when you're working on different props.

Other than that, great job!
 Post #27
 27th April 2007
darkstar7878's Avatar
May 2006
230 Posts
Thank you so much, I wish I could rate you twice... but I'm just gonna rate you winner... Because you are a winner. :P
 Post #28
 27th April 2007
Syranide's Avatar
April 2007
453 Posts
[QUOTE=AfTeRsHoCk]
NisseOwned posted:
Oh snap!
...QUOTE]

Indeed.

One suggestion though, could you add a feature so that it allows you to change the settings of the snap-grid via something other than the settings menu? Like, maybe a second context panel or something equally (most likely) impossible and ridiculous.

It's just kind of a hassle to keep going back and forth between the STool menu and the settings menu when you're working on different props.

Other than that, great job!
The best I can come up with at the moment is console command for those that you can bind to different buttons (increase/decrease size). Possibly if I have time I might add a secondary button instead, which would bring up something like a quick options-dialog where the cursor is, allowing you to edit the most common ones.
 Post #29
 27th April 2007
Naes Draw's Avatar
March 2007
353 Posts
This is handy.
 Post #30
 27th April 2007
AfTeRsHoCk's Avatar
May 2005
394 Posts
Syranide posted:

The best I can come up with at the moment is console command for those that you can bind to different buttons (increase/decrease size). Possibly if I have time I might add a secondary button instead, which would bring up something like a quick options-dialog where the cursor is, allowing you to edit the most common ones.
That would great, awesome, thanks! :D
 Post #31
 27th April 2007
Sam_!00!'s Avatar
March 2007
274 Posts
Razot posted:
um... what does it do

(User was banned for this post (Reason: RCP (in post "Re: SmartSnap (snap the mouse to objects)" by garry)))
Garry is not amused!

Anyway back on topic...

Nice!
 Post #32
 27th April 2007
Mr.123's Avatar
February 2006
1,264 Posts
Good job I used the regular autosnap all the time for wire mod but it always messed up.
 Post #33
 27th April 2007
Sam_!00!'s Avatar
March 2007
274 Posts
Holy shit!

Awesomeness!
 Post #34
 27th April 2007
dkikisb's Avatar
April 2007
53 Posts
Great! Have to try this out!
 Post #35
 27th April 2007
Gold Member
Roo-kie's Avatar
August 2006
11,325 Posts
According to you, what are 'bad' angles?
 Post #36
 27th April 2007
Syranide's Avatar
April 2007
453 Posts
Roo-kie posted:
According to you, what are 'bad' angles?
Bad angles are if you are looing at an angle not straight at the face of the prop (if you are looking from the side or not so to speak, in mathematical terms, the angle between your viewing angle and the normal of the face), if the prop has an uneven surface or not correctly offset grid then the placement of the object will not be perfectly centered if you are looking from the side, therefore I have set the cursor to indicate green at 10 degrees and yellow at 20 degrees... for normal squared props with correctly offset grid, it shouldn't matter at all.

EDIT: on another note, I am working on the offsetting for the grid and it is working out very nicely and easy to work with, although I have to add another offset for offsetting the grid from the edges too (because some props actually have bigger collission boxes than what they "should have", like the red dumpster, these will have the possibility of offsetting the grid from the edges as well. Although there is still some way to go to get it all working (needs a "dev mode" so that it is easier to position the grid and so on).

Here is a picture of the dumpster having perfectly slimmed bounding box (although note that for the dumpster it is stupid because it really is bigger, but to show the concept, the white dumpster is just because it is easier to see)

 Post #37
 27th April 2007
Guest
mblunk's Avatar

n/a Posts
Can you make a mirror please, garrysmod.org isn't working for me right now.

Edit:

Please? I'll make a promotional video for you if you do. I've made promo videos for an old gmod9 fireworks script, ULX and the Tool Turrets addon.
 Post #38
 27th April 2007
Syranide's Avatar
April 2007
453 Posts
mblunk posted:
Can you make a mirror please, garrysmod.org isn't working for me right now.
It has been done! VS-SH should be fine I presume.
 Post #39
 27th April 2007
jaybuz's Avatar
May 2006
1,309 Posts
mblunk posted:
Can you make a mirror please, garrysmod.org isn't working for me right now.

Edit:

Please? I'll make a promotional video for you if you do. I've made promo videos for an old gmod9 fireworks script, ULX and the Tool Turrets addon.
Lol blunk you make me laugh.
 Post #40
 27th April 2007
Guest
mblunk's Avatar

n/a Posts
jaybuz posted:
Lol blunk you make me laugh.
How so?

Edit:

Syranide posted:
It has been done! VS-SH should be fine I presume.
Do you have a specific due date you'd like the movie at? If you want it fast, I could get you a view within a few hours, but it probably wouldn't be very good. If you don't care when you get it, I could get you something real nice by the end of the weekend.
 Post #41
 27th April 2007
Stryder786's Avatar
February 2007
562 Posts
This is really awesome.
 Post #42
 27th April 2007
Gold Member
sharpshark28's Avatar
February 2005
4,401 Posts
This is amazingly perfect. This will always from now on be the FIRST thing I install whenever I redo Gmod.

Also, is there a way to make a toggle key for the grid? (To turn on and off) Because a friend and I play a retarded game together that grid ruins the fun of :P (varient of hide and seek)

Thanks! King'd
 Post #43
 27th April 2007
Rysoke24's Avatar
July 2006
1,464 Posts
Nice! ^ I'm that friend.
 Post #44
 27th April 2007
Leon_307's Avatar
April 2007
584 Posts
This is a copy of Locklear's Autosnap!
 Post #45
 27th April 2007
TwingeCrag's Avatar
July 2006
1,161 Posts
Leon, are you disabled?
 Post #46
 27th April 2007
Rysoke24's Avatar
July 2006
1,464 Posts
TwingeCrag posted:
Leon, are you disabed?
I don't know if you should be calling people disabled -> You spelled, disabled wrong.
 Post #47
 27th April 2007
Q42's Avatar
August 2006
1,939 Posts
I know there's already one of these, but this one looks a HELL of a lot better, being that you don't have to be point-blank to work on things. That part with the nail gun. WOW.
 Post #48
 27th April 2007
zlatko's Avatar
January 2005
103 Posts
Very nice! Makes building with precision much easier. This is definitely going on my server, gold star for you!
 Post #49
 27th April 2007
Q42's Avatar
August 2006
1,939 Posts
Just tried it out and... well... you are my god now.

Building the temple may take awhile though. lazy you see. [spoiler]need a smartsnap for real life :P[/spoiler]
 Post #50
 27th April 2007
Syranide's Avatar
April 2007
453 Posts
Thank you all for the very positive feedback which is very inspiring to receive, and know that I am still working on it and are planning to improve it over time, as you might've read above, I'm currently working on setting per-model offsets so that it is possible to create perfect snaps for every predefined model. It now also saves the settings and it is possible to map a user key to snap instead of default (USE), these among others will be in the next version.

sharpshark28 posted:
This is amazingly perfect. This will always from now on be the FIRST thing I install whenever I redo Gmod.

Also, is there a way to make a toggle key for the grid? (To turn on and off) Because a friend and I play a retarded game together that grid ruins the fun of :P (varient of hide and seek)

Thanks! King'd
You can turn off the grid in the options (I'm guessing you don't actually need a key for it?), or use the console variable "snap_enabled 0". (just for fact, it is possible to bind this console var to a key too that would make it toggle)

Leon_307 posted:
This is a copy of Locklear's Autosnap!
It is not a copy, it's a remake, one that apparently was appreciated. And I've added credit to locklear now as I wasn't aware of that he was the original inspiration.

Q42 posted:
Just tried it out and... well... you are my god now.

Building the temple may take awhile though. lazy you see. [spoiler]need a smartsnap for real life :P[/spoiler]
I'll see what I can do about that, a temple would indeed be nice
 Post #51
 28th April 2007
Gold Member
s0ul0r's Avatar
September 2006
3,217 Posts
Lua king'd
 Post #52
 28th April 2007
Gold Member
Vampired's Avatar
February 2005
2,269 Posts
I'm going to Lua King you Syranide.

This script is excellent. I can see that you have worked hard on this.

I like how it runs smoothly, how it smartly chooses the size of the grid, how neat and shiny your code is, and also how I can walk around and it will still snap to the original point with no problem.

However, I don't like pressing lots of keys at once for example E to snap and W, A to move for example. So I decided to edit your code a bit to enable it to toggle.

Hope you don't mind but here's what I came up with.

Press to toggle on, press to toggle off. Press and hold will toggle on, release will toggle off.

...
-- Starts about line 115.

-- Added these local variables, move them or rename them if you need.
local toggled = false
local lastpress = 0
local function OnPaintHUD()
	if (GetConVarNumber("snap_enabled") == 0) then return end

	-- Moved these two lines before the 'target.locked = ...' and 'target.active = ...'
	if (!player:IsValid()) then return end
	if (!player:Alive() or !player:GetActiveWeapon():IsValid()) then return end
	
	-- Added this section.
	if (player:KeyDown(IN_USE)) then
		if(lastpress == 0) then
			toggled = !toggled
			lastpress = CurTime()
		end
	else
		if(lastpress > 0 and CurTime() > lastpress + 0.5) then
			toggled = false
		end
		lastpress = 0
	end
	if(!target.active) then toggled = false end
	-- End
	
	-- Changed 'player:KeyDown(IN_USE)' to 'toggled'
	target.locked = toggled and target.active == true
	target.active = false
	...

Also another thing that bugged me was if you got too close to or inside the prop then the lines would go in the wrong direction.

Lastly, I saw you say you were going to be able to save the options and I also saw the /data/defaults.txt so are you going to save to a text file? I more simpler way would be to use.

-- Third argument to true makes the convar save.
CreateClientConVar("snap_enabled", 1, true, false)

Thanks for the great script.
 Post #53
 28th April 2007
Gold Member
aVoN's Avatar
December 2005
7,891 Posts
Aimbot!
Will install this very interesting script soon.
 Post #54
 28th April 2007
Gold Member
Robbis_1's Avatar
July 2005
3,864 Posts
Ahh.. A fresh remake of the Autosnap. Have to say it's about time, because I'm getting a little rusty (no time :() nowadays and that script was like 4 months old.
Interesting feedback you get though (that I didn't get), which made me stop updating it.
 Post #55
 28th April 2007
Gold Member
Vampired's Avatar
February 2005
2,269 Posts
Yours was good too Robbis_1 :D
 Post #56
 28th April 2007
Gold Member
Robbis_1's Avatar
July 2005
3,864 Posts
Vampired posted:
Yours was good too Robbis_1 :D
Durr... Apparently not good enough.
But nothing can be perfect, can it?
 Post #57
 28th April 2007
Syranide's Avatar
April 2007
453 Posts
Vampired posted:
I'm going to Lua King you Syranide.

This script is excellent. I can see that you have worked hard on this.

I like how it runs smoothly, how it smartly chooses the size of the grid, how neat and shiny your code is, and also how I can walk around and it will still snap to the original point with no problem.

However, I don't like pressing lots of keys at once for example E to snap and W, A to move for example. So I decided to edit your code a bit to enable it to toggle.

Hope you don't mind but here's what I came up with.

Press to toggle on, press to toggle off. Press and hold will toggle on, release will toggle off.

...

Also another thing that bugged me was if you got too close to or inside the prop then the lines would go in the wrong direction.

Lastly, I saw you say you were going to be able to save the options and I also saw the /data/defaults.txt so are you going to save to a text file? I more simpler way would be to use.

-- Third argument to true makes the convar save.
CreateClientConVar("snap_enabled", 1, true, false)

Thanks for the great script.
Hey there!
Although I have to say not all the code is so neat and shiny yet, but it hopefully will be ;)

Excellent idea there, I have support in the current version for snapping to the grid with other keys using console commands, and I guess you can make it toggle by binding in a specific way too, although what you suggest there using both snap and lock (using delay) is really really great, definately available in the next version.

Regarding the lines, there is no fix for that that I know of, it's ToScreen() in garrysmod that messes up when you get too close (probably something with the projection, because it often just flips to the wrong side and so on) ... I will have a look at this further on, as I think it is possible it to solve using a slightly slower method.

Saving the options, using CreateConVar(..., ..., true, ...) doesn't save it (cold12141 ;)), that only implies that a convar is saved when you save a game (I've tried it, resets everytime you restart) ... but I have implemented a custom method for saving the settings (also next release). I've looked around, although I know this is automatic for TOOLs, I haven't found a way to create global convars without having a tool.

"defaults.txt" is not intended for settings, it's basically just a placeholder for default prop offsets for the grid, when it is available (working on this at the moment).

Of course I don't mind, this is EXACTLY the kind of ideas that I want, reasonable, useful and simple to use.

Robbis_1 posted:
Ahh.. A fresh remake of the Autosnap. Have to say it's about time, because I'm getting a little rusty (no time :() nowadays and that script was like 4 months old.
Interesting feedback you get though (that I didn't get), which made me stop updating it.
I am very glad that you feel that way, I believe your autosnap was widely appreciated although everyone might not have expressed their gratitude, apparently, people never stopped using it once they tried it ;) me neither ... (and you see where it got me ) (it's sad that more people don't see the power in the simplest of feedback, which has brought many addons to a standstill)
 Post #58
 28th April 2007
Gold Member
Skorpy's Avatar
July 2005
4,207 Posts
I usually don't like that people go and recreate a something that someone has already done.
But if creator of the first one says the second one is good or better, I quess I just have to download it then...:S
 Post #59
 28th April 2007
terrorclaw's Avatar
March 2005
711 Posts
I have used the first, and this reads like it will be a lot better, going to try it here in a bit.
 Post #60
 28th April 2007
cold12141's Avatar
October 2005
359 Posts
Syranide posted:
Saving the options, using CreateConVar(..., ..., true, ...) doesn't not save it, that only implies that a convar is saved when you save a game (I've tried it, resets everytime you restart) ... but I have implemented a custom method for saving the settings (also next release). I've looked around, although I know this is automatic for TOOLs, I haven't found a way to create global convars without having a tool.
)
So, what you're saying is that it does save it when use a con var? Two negatives makes a positive =) Just kidding, great script. Already on my two servers.
 Post #61
 28th April 2007
Gold Member
Vampired's Avatar
February 2005
2,269 Posts
Syranide posted:
Saving the options, using CreateConVar(..., ..., true, ...) doesn't not save it, that only implies that a convar is saved when you save a game (I've tried it, resets everytime you restart) ... but I have implemented a custom method for saving the settings (also next release). I've looked around, although I know this is automatic for TOOLs, I haven't found a way to create global convars without having a tool.
That's strange I was almost sure it did. Although I haven't tried it I found /cfg/gmod_cvars_cl.txt is where all the values are stored including gmod_toolmode. This is the line where gmod_toolmode convar is defined:

gmod_toolmode = CreateClientConVar( "gmod_toolmode", "rope", true, true )

Maybe I'm wrong, but if you already have a method for saving it's probably good. Good luck on this.
 Post #62
 28th April 2007
gilly_54's Avatar
June 2006
932 Posts
This is great, the camera lock on is perfect. (By the way, does placing the nailer from across the map in the video remind anyone of a cheesy viagra ad?)
 Post #63
 28th April 2007
Syranide's Avatar
April 2007
453 Posts
0.8.1 (major changes)
● There is now a lock snap mode, that will keep the snap without holding a key by binding a key to "snaplock" (idea by Vampired)
● Based on the previous there is now a smart snap lock that will activate after a short delay, off by default, adjustable delay (idea by Vampired)
● The snap button can now be assigned to another key by binding that key to "+snap", "snap_disableuse 1" to disable default snap key
● The settings are no longer lost when restarting the game

There are some other minor changes, you can now set the grid offset by hand (until the per-model grid offset is available). And some other minor things.

Per-model grid offsets are coming along pretty nicely, and should be available pretty soon.

Vampired posted:
That's strange I was almost sure it did. Although I haven't tried it I found /cfg/gmod_cvars_cl.txt is where all the values are stored including gmod_toolmode. This is the line where gmod_toolmode convar is defined:

gmod_toolmode = CreateClientConVar( "gmod_toolmode", "rope", true, true )

Maybe I'm wrong, but if you already have a method for saving it's probably good. Good luck on this.
I'll have to look into that, but from what I can see, that is a tool (tools have convars that automatically save, I haven't found any similar support for hooks/generic lua)... I now save them myself instead into a file (works, but would be much more neat with convars saved the "correct" way, if possible, so I'll look further into it sometime).

Implemented your idea with the "lock snap", although I rewrote it all because I found many more "advanced" uses for it (now you can lock snap, and then bring up the context menu, and walk around the prop) ... and a lot of special cases, you don't want lock snap in the content menu and so on, etc etc... Superb idea and you have been given credits for it!
 Post #64
 28th April 2007
luck_or_loss's Avatar
January 2007
1,281 Posts
Nice job, this is a pro-builder must-have. Gold star and a Download!
 Post #65
 28th April 2007
Gold Member
Vampired's Avatar
February 2005
2,269 Posts
I'd try this new version but my Steam isn't working right. :S
 Post #66
 28th April 2007
dkikisb's Avatar
April 2007
53 Posts
New release , good job! This is very useful! Thanks!
 Post #67
 28th April 2007
TwingeCrag's Avatar
July 2006
1,161 Posts
Rysoke24 posted:
I don't know if you should be calling people disabled -> You spelled, disabled wrong.
Are you sure that wasn't intentional? [spoiler]I feel stupid [/spoiler]
 Post #68
 28th April 2007
Q42's Avatar
August 2006
1,939 Posts
Don't feel stupid! [spoiler]feel DISABED! [/spoiler]
 Post #69
 29th April 2007
Gold Member
kirderf's Avatar
October 2005
4,577 Posts
If i install this on my server, can peoples who join use it?
 Post #70
 29th April 2007
Gold Member
Vampired's Avatar
February 2005
2,269 Posts
You will have to put
AddCSLuaFile("client.lua")
AddCSLuaFile("menu.lua")

in a separate file in /autorun/server/ to make it send to the clients.

Anyway Syranide, I just testing this out and it's even better, the delay thing is much better than what I did.

Edit: That reminds me, I think you should change the file names of client.lua and menu.lua because if another addon uses the same file names one of them will be overwritten.
 Post #71
 29th April 2007
spbogie's Avatar
June 2006
186 Posts
As long as they remain in their individual addon directories there is no problem with the names.
 Post #72
 29th April 2007
Syranide's Avatar
April 2007
453 Posts
I'm happy to announce that I have now implemented per-model offsets, for square props you can now have a perfectly aligned grid AND perfectly placed objects (you can place props even at 85 degrees without any error) as there now is a snap-offset too that displaces the cursor to the bounding box, while allowing you to have a grid that is consistent with what you see.

Although! I will not release it just yet, and that is not because I want to hold it back, or tease you, it's because I'm working on something even greater and if successful would allow you to place objects with perfect precision even on round and uneven surfaces! That does not imply a grid that aligns to the curvature of the object, but rather that the mouse is displaced according to the surface, so although you wouldn't get evenly spaced placement for round objects, you could easily have symmetrical placement or aligned placement.

So hold on to your hats!

Vampired posted:
You will have to put
AddCSLuaFile("client.lua")
AddCSLuaFile("menu.lua")

in a separate file in /autorun/server/ to make it send to the clients.

Anyway Syranide, I just testing this out and it's even better, the delay thing is much better than what I did.

Edit: That reminds me, I think you should change the file names of client.lua and menu.lua because if another addon uses the same file names one of them will be overwritten.
Glad that you like it! (I did! ;))
I'll look into that with the filenames, although I'm fairly sure what spbogie said is correct, but I'll see what I can find just to be on the safe side.
 Post #73
 29th April 2007
Gold Member
Elspin's Avatar
December 2006
5,153 Posts
Nevermind saw it in original post. Looks great :)
 Post #74
 29th April 2007
Overkill1010's Avatar
October 2006
103 Posts
I have no idea what you just said in your post #72 Syranide but this tool is freaking awesome! Glad to see a new version. Here have another Lua King. Oh and here's a cookie ;P.
 Post #75
 29th April 2007
Gold Member
DrMonumbo's Avatar
January 2006
10,433 Posts
looks like an aimbot... not that I'd know what that looks like...
 Post #76
 29th April 2007
Syranide's Avatar
April 2007
453 Posts
Overkill1010 posted:
I have no idea what you just said in your post #72 Syranide but this tool is freaking awesome! Glad to see a new version. Here have another Lua King. Oh and here's a cookie ;P.
COOKIE!

And here is a cookie for you!
Perhaps this will put my words into something more tangible ;)


Perfectly aligned placement on non-square props, works well on uneven too (but note the grid and the spacing, this is because as you can see the grid does not follow the entity, but the mouse is displaced towards the entity instead, however, I will most likely add a "sine grid" or something that will allow you to position perfectly on round objects (while still having a box grid))

Although there are still some kinks in it, so no promises, but it is looking very promising, another important consequence of this is that it now works on any prop without predefining any stuff. Only the grid needs to be offset, and there is no longer explicit need for it as it mostly serves as a visual aid (and to make edges usable).

EDIT: LOL, I just found out what was causing the major kink... on certain props it would spawn very oddly, and try to spawn it in the air, I just found out why... it was TOO precise it kept hitting exactly where the model-seams were, and obviously some bug made it possible to then spawn them inside the prop (I'll just have to add an (insignificantly) small error margin for when that happens)
 Post #77
 29th April 2007
Gold Member
conman420's Avatar
January 2007
4,644 Posts
Before you release can you put some sort of marker where the half way spot is?
 Post #78
 29th April 2007
E104 Epsilon's Avatar
February 2007
1,147 Posts
Razot posted:
um... what does it do

(User was banned for this post (Reason: RCP (in post "Re: SmartSnap (snap the mouse to objects)" by garry)))
 Post #79
 29th April 2007
Syranide's Avatar
April 2007
453 Posts
conman420 posted:
Before you release can you put some sort of marker where the half way spot is?
I'm not exactly sure what you mean.
But for clarity, there will be two modes (toggle):
1. the mouse will look at the "grid snap" (but you will actually shoot at the "shoot snap")
2. the mouse will look at the "shoot snap" (and revert to the grid when the snap is released)

And obviously, since the gap between the "grid snap" and "shoot snap" can be quite big there will be some visual que to where it will be placed, I will be trying different methods for this.
 Post #80
 29th April 2007
Overkill1010's Avatar
October 2006
103 Posts
Ohh i get it now Syranide, thanks. Here, have another cookie! :D.
Reply


All times are GMT. The time now is 04:24PM.

Facepunch Studios 2009 - Server 'Softlayer 2.0'