Pinkerten
|
  |
| Joined: 03 Aug 2014 |
| Total Posts: 840 |
|
|
| 21 Sep 2015 06:18 PM |
I'm looking for simple little functions that I could use, like rounding, and easy color3, yeah stuff like that.
So far I have this, please add to it!
local module = { ["color"] = function(r,b,g) return Color3.new(r/255,b/255,g/255) end, ["round"] = function(num,a) return math.floor(num/a+.5)*a end } return module |
|
|
| Report Abuse |
|
|
Pinkerten
|
  |
| Joined: 03 Aug 2014 |
| Total Posts: 840 |
|
|
| 21 Sep 2015 06:38 PM |
| Thanks for all your input! |
|
|
| Report Abuse |
|
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
|
| 21 Sep 2015 06:43 PM |
| Heres 1 :SIKE!!!!!!!!!!! Wrong Fourm, Go to script helper or LMAD. |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2015 06:45 PM |
@ booing
You truly are an idiot, aren't you? |
|
|
| Report Abuse |
|
|
booing
|
  |
| Joined: 04 May 2009 |
| Total Posts: 6594 |
|
|
| 21 Sep 2015 08:48 PM |
| And you are the bigger idiot For responding to me especially when i wasnt talking to you, Looks like you need to read my post too. |
|
|
| Report Abuse |
|
|
Pinkerten
|
  |
| Joined: 03 Aug 2014 |
| Total Posts: 840 |
|
|
| 22 Sep 2015 07:04 PM |
| Scripting Helpers no longer exists and lmad isnt the place for this anyway? |
|
|
| Report Abuse |
|
|
notfruit
|
  |
| Joined: 21 Sep 2012 |
| Total Posts: 1386 |
|
|
| 22 Sep 2015 07:07 PM |
the only way I know how you could round is using an atrocious regex hack (casting to str, then using regex, modifying string, and back to int)
You don't need to wrap the Color3 constructor. If you do it everyone will laugh at you. |
|
|
| Report Abuse |
|
|
Pinkerten
|
  |
| Joined: 03 Aug 2014 |
| Total Posts: 840 |
|
|
| 22 Sep 2015 07:08 PM |
| What are you talking about? I just want a bunch of simple functions such as the ones I have. |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2015 07:17 PM |
module.numbersOnly = function(string) if ((not string) or (type(string) ~= "string")) then return (string and type(string) == "number" and string or 0) end return (tonumber(string) or tonumber(string:match("%-?%d+%.?%d*")) or 0) end
module.assetExists = function(Asset, AssetType) -- 15 is audio return pcall(function() local AssetTypeId = MarketplaceService:GetProductInfo(Asset).AssetTypeId if AssetTypeId == AssetType then return true else return false end end) end |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 22 Sep 2015 07:18 PM |
| Oh god no, only check with tonumber |
|
|
| Report Abuse |
|
|
Pinkerten
|
  |
| Joined: 03 Aug 2014 |
| Total Posts: 840 |
|
|
| 22 Sep 2015 07:20 PM |
@climax
I have no idea what the first function is used for and the second function is beyond useless because I check my assets before I put them into the game. |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2015 07:40 PM |
| the first function is used to reduce a string to only numbers and the second function is useful if the asset is entered by a client |
|
|
| Report Abuse |
|
|
Pinkerten
|
  |
| Joined: 03 Aug 2014 |
| Total Posts: 840 |
|
|
| 22 Sep 2015 07:42 PM |
thats a terrible function #number1
["tonumbers"] = function(string) return string.byte(string,1,#string) end |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2015 11:10 PM |
that's not what i meant stop being a nob
> "hey this is my 6th time" > 6
and yeah it could be shortened a tad but i didn't take the time to revise it |
|
|
| Report Abuse |
|
|
|
| 22 Sep 2015 11:20 PM |
here's a handy one. not to go in the module, to go right after the module is declared.
setmetatable(module, { __call = function(self) local fenv = getfenv(2) for Name, Value in pairs(self) do fenv[Name] = Value fenv[Name:lower()] = Value end end; }) Then you can require it like require(module)() and everything is in your fenv Also function cutout(string, substring) string:gsub(substring, '') end
--ThatChristianGuy is lonely. Join me on http://www.roblox.com/Forum/ShowPost.aspx?PostID=123008267 |
|
|
| Report Abuse |
|
|