|
| 04 Dec 2015 04:13 PM |
For anyone who cares,
https://github.com/Hydroque/LuaUtil
I threw together a bunch of libraries and update things here. Extracted some from my projects. Take a look.
I don't want any discussion about how you don't like OOP btw. |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 04:22 PM |
pi2 = 6.283185306;
No.
tau = math.pi*2; |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 04:26 PM |
Math.pythag = function(x, y) return math.sqrt(x * x + y * y) end
No.
Math.pythag = function(h, o, a) if not h then return math.sqrt(o^2+a^2) elseif not o then return math.sqrt(h^2-a^2) elseif not a then return math.sqrt(h^2-o^2) elseif h and o and a then return math.sqrt(o^2+a^2) == h else return error("Only 1 value specified to Math.pythag", 2) end end |
|
|
| Report Abuse |
|
|
| |
|
|
| 04 Dec 2015 04:28 PM |
local Table = {}
-- arranges elements in a dictionary that represents how many terms there are in a given table -- tab the given table to be evaluated -- for each number found, it will, at the number as index, add, or start at, 1 in the dictionary Table.count = function(tab) local out = {} for i=1, #tab do out[tab[i]] = out[tab[i]] and out[tab[i]] + 1 or 1 end return out end
return Table
No.
http://www.roblox.com/ExtendedTable-item?id=199207348
Credit pl0x. |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 04:30 PM |
'local this = { X = x or 0; Y = y or 0; }'
No.
Just wrap this: http://wiki.roblox.com/index.php/Vector2 |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 04:31 PM |
| And those are my opinions :D (Constructive criticism of course, nice job so far.) |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 04:49 PM |
"No.
tau = math.pi*2;" No. It makes sense how I did it.
"No.
Math.pythag = function(h, o, a) if not h then return math.sqrt(o^2+a^2) elseif not o then return math.sqrt(h^2-a^2) elseif not a then return math.sqrt(h^2-o^2) elseif h and o and a then return math.sqrt(o^2+a^2) == h else return error("Only 1 value specified to Math.pythag", 2) end end" This way does nothing but have 3 variables that are acted on the same way. Having this, you just create redundancy. asset() is bae in this occasion. Anyways, I don't need to do any comparison, as the Math.pythag only executes Pythagorean Theorem. There is absolutely no reason to do - anything, as it will just error because you can't sqrt a - number. Don't be stupid.
I have not even extended the Table library yet. Evidently organizing each index to have the key to be a number found and having it set to the occurrences is so bad that I need a library shown to me. I am not going to check it out, thanks.
"No.
Just wrap this: http://wiki.roblox.com/index.php/Vector2"
This has nothing to do with Roblox Lua. |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 04:59 PM |
'This way does nothing but have 3 variables that are acted on the same way. Having this, you just create redundancy. asset() is bae in this occasion. Anyways, I don't need to do any comparison, as the Math.pythag only executes Pythagorean Theorem. There is absolutely no reason to do - anything, as it will just error because you can't sqrt a - number. Don't be stupid.'
I didn't sqrt any negatives. I made it support the other 2 sides, as well at return if the 3 numbers are valid (assuming 3 numbers are passed in) |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 05:01 PM |
'I have not even extended the Table library yet. Evidently organizing each index to have the key to be a number found and having it set to the occurrences is so bad that I need a library shown to me. I am not going to check it out, thanks.'
I wasn't saying the library was bad. I was pointing you to my module so you could get some ideas. |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 05:02 PM |
"I didn't sqrt any negatives." elseif not o then return math.sqrt(h^2-a^2) elseif not a then return math.sqrt(h^2-o^2)
"I made it support the other 2 sides," Your point has no been made.
It returns nil if failed btw. |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 05:02 PM |
| And how you answer to errors is not based on you, but the user. Maybe they want to expect nil and not get a useless error thrown at them. |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 05:07 PM |
'"I didn't sqrt any negatives." elseif not o then return math.sqrt(h^2-a^2) elseif not a then return math.sqrt(h^2-o^2)
"I made it support the other 2 sides,"'
Perhaps I should explain this to you. A triangle has 3 sides. The hypotenuse, opposite side and the adjacent. Represented here by the arguments h, o, and a. The hypotenuse is defined as the longest side of a triangle. This therefore means the opposite/adjacent is shorter. So h > a and h > o. Now you'd imagine h-a or h-o, given h is greater, the result would be positive.
@error point, alright, I usually spit out a warning, I don't know why I said error |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 05:12 PM |
Right, but you just simply allow them to add data in any order not realizing it doesn't matter.
Opposite and Adjacent doesn't matter as they are taken into account. The Hypotenuse is what you solve for when you pythag something. If you want to calculate another way, I would put another function in Math because switching through if statements until you find the one you need is redundant.
|
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 05:14 PM |
| Well then you include it in the docs. The pythag theorem is used to find the missing side of a triangle, not just the hypotenuse. You have to rearrange the equation, which I did. |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 05:16 PM |
I somewhat agree, but I am adding tau into as pi2. I am going to start using tau for my circle calculations. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 04 Dec 2015 05:59 PM |
| You correcting his pythag made you look like an idiot warspy. |
|
|
| Report Abuse |
|
|
|
| 04 Dec 2015 07:51 PM |
| I can't possibly see how this is so. Could you possibly help me to come to the conclusion on why you believe that to be true? |
|
|
| Report Abuse |
|
|
k9rosie
|
  |
| Joined: 05 Jul 2008 |
| Total Posts: 14339 |
|
|
| 04 Dec 2015 08:58 PM |
| congrats on releasing your first library. |
|
|
| Report Abuse |
|
|