Ulysses

General => Developers Corner => Topic started by: sodak on September 23, 2016, 03:56:26 PM

Title: Command for ulx bring all
Post by: sodak on September 23, 2016, 03:56:26 PM
Hey i need a command when i type in !bringall it teleports all players to me like ulx bring *  but this dont work.

Is there any quick and dirty code for this?
Title: Re: Command for ulx bring all
Post by: Bytewave on September 24, 2016, 08:24:02 AM
I've considered something like this in the past, but there's a fundamental problem: How do you find positions for every player such that they aren't inside of walls, props, each other, etc?

It may be feasible, but it'd require a good bit of work. So, no, there's no "quick 'n' dirty" method of getting this done right.
Title: Re: Command for ulx bring all
Post by: Megiddo on September 24, 2016, 11:31:30 AM
Bytewave, probably the easiest would be to check every ten degrees around the "bringer" at 50 units out (or whatever), then every five degrees around the "bringer" at 100 units out, then every two and a half degrees at 200 units out, etc. Using hull traces, this should work even in a tight hallway as long as you have enough free space within line-of-sight. You could give up on a full trace and just make sure there's enough room for the player at the destination, at the risk of the person being brought ending up on the other side of a wall from the person they were brought to.
Title: Re: Command for ulx bring all
Post by: JamminR on September 24, 2016, 06:55:57 PM
/me imagines changing PlayerArg to PlayersArg and adding a for players.getall statement in the code just to see if the Gmod map point swirls into a black hole gravity well.
Title: Re: Command for ulx bring all
Post by: Timmy on October 31, 2016, 09:20:57 AM
Made a command that can bring multiple players. I had never really used vectors, angles or traces before. This was a great way to experiment with them. :)

I hope these bots brought their towels! ;D
(https://timmy.github.io/images/ulx-bring-animation.gif)

I made sure it can handle smaller spaces.
(https://timmy.github.io/images/ulx-bring-packed.png)



Attached the command in addon format, in case anyone wants the code.

Usage: ulx tbring <players> [<number: 33<=x<=200, default 50>] - Teleports target(s) to you. (say: !tbring)

The second, optional, parameter can be used to control the space between each player:
Cram players in like sardines: !tbring * 33
Or, give them lots of free space: !tbring * 200

Happy halloween!

Edit: Updated command to remove an unnecessary trace.
Title: Re: Command for ulx bring all
Post by: Stickly Man! on October 31, 2016, 10:13:47 AM
Nice work, Timmy! ;D
Title: Re: Command for ulx bring all
Post by: Megiddo on November 12, 2016, 02:46:18 PM
Timmy's new function is now built into ULX (GitHub only until release). :)
Title: Re: Command for ulx bring all
Post by: Timmy on November 13, 2016, 07:27:56 AM
Yay, awesome!

@Megiddo: It's really cool to see the changes you made. I particularly like how you generate the spiral grid... so much more efficient. I can tell that I still have a lot of room for improvement. Do you perhaps have any feedback? Was my code hard to understand? :)
Title: Re: Command for ulx bring all
Post by: Megiddo on November 13, 2016, 02:22:59 PM
Sure, happy to provide feedback.

The main changes I made are as follows (in order of subjective importance):
Some of these are merely preferences, but I always prefer shorter, clearer code where possible. I add efficiencies where it does not overly damage the first two objectives (unless it's in a critical section of code, like a hook library). An excellent book along these lines is Clean Code by Robert Martin (https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882).

Your code was not terribly difficult to understand, especially given that it wasn't that many lines of code and I understood the overall trajectory of what you were trying to accomplish. I would suggest comments in the more "sticky" spots, though -- both for yourself and others. For example, it took me a while to work out how I was going to accomplish the grid function, and I added comments which explain what's being generated where.
Title: Re: Command for ulx bring all
Post by: Timmy on November 14, 2016, 09:53:52 AM
I really appreciate the feedback. These are things I will keep in mind going forward. I've seen 'Clean Code' in my school library, will definitely check out the book. Thank you!