Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[ ** *** *** *** ** *** *** *** ** ]]
- --[[ ** SunShineSilver.mdA 2019-03 ** ]]
- --[[ ** *** *** *** ** *** *** *** ** ]]
- --[[ mdA_LuaPlugin.lua ]]
- --[[ Print Function]]
- function _p(rint) print(rint) end
- --[[ String _Functions() #short ]]
- --function _nil(s) if s == nil or s == '' then _p("..got no value(nil)") return true else return false end
- function _find(s) return string.find(s) end
- function _sub(s,v1,v2)if v2~=nil then return string.sub(s,v1,v2) else return string.sub(s,v1) end end
- function _len(s) return string.len(s) end
- function _gsub(s,pat,rep) return string.gsub(s,pat,rep) end
- function _char(i1, i2,...) return string.char(i1, i2,...) end
- function _match(s,pat,inlen_) return string.match(s,pat,inlen_) end
- function _byte(s,i,j) return string.gmatch(s,pat) end
- function _dump(_function) return string.dump(_function) end
- function _replay(s,replay) return string.rep(s,replay) end
- function _format(s,e1,e2,...) return string.format(s,e1,e2,...) end
- function _reverse(s,replay) return string.reverse(s) end
- function _low(s) return string.lower(s) end
- function _upp(s) return string.upper(s) end
- --[[subfunc]]function ___Title(first,rest) return first:upper()..rest:lower()end--[[subfunc]]
- function _title(s) return _gsub(s,"(%a)([%w']*)",___Title) end;
- function ToTitle(s) return _title(s)end
- -- >> "(%a)([%w_']*)" <<-with "_" = Array_data_verify and not Data_Verify_Event
- -- string.find(s, pattern [, index [, plain]])
- -- string.format(s, e1, e2, ...)
- -- string.gmatch(s, pattern)
- -- string.gsub(s, pattern, replace [, n])
- -- string.len(s)
- -- string.lower(s)
- -- string.upper(s)
- -- string.match (s, pattern [, index])
- -- string.rep(s, n)
- -- string.reverse(s)
- -- string.sub(s, i [, j])
- -- string.char(i1, i2, ...)
- -- string.byte(s [, i [, j]])
- -- string.dump(function)
- function DecToHex(decimalIN) -- convert decimal to hex value
- local decimalDO = decimalIN
- local hexValue = string.format("%X", decimalDO)
- local hexOUT = tostring('0x'..hexValue)
- return hexOUT
- end
- function HexToDec(hexIN) -- convert hex to decimal value
- local decOUT = tonumber("0x"..hexIN)
- decOUT = string.format("%X", decOUT)
- return decOUT
- end
- function string.fromhex(str)
- return (str:gsub('..', function (cc)
- return string.char(tonumber(cc, 16))
- end))
- end
- function convert(inp)
- if (not inp) then
- return false;
- end
- local a,b = tonumber(inp),tonumber('0x'..inp) -- decimal/hex
- if (a) then
- return a;
- elseif(b) then
- return b;
- end
- end
- function string.tohex(str) return (str:gsub('.', function (c) return string.format('%02X', string.byte(c)) end)) end
- function string.trimstart(s, c) if (not c) then c = ' '; end s = string.reverse(s); s = string.trimend(s, c); return string.reverse(s); end
- -- desc: Trims the end of a string for whitespace.
- function string.trimend(s, c)
- if (not c) then c = ' '; end if (string.sub(s, -1) == c) then
- s = string.sub(s, 0, -2); s = string.trimend(s, c);
- end return s;
- end
- -- desc: Trims a string of whitespace.
- function string.trim(s, c) if (not c) then c = ' '; end
- s = string.trimstart(s, c); s = string.trimend(s, c);
- return s;
- end -- desc: Converts the given string to a hex array string.
- function str2hexstr(str)
- local ret = ''; for x = 1, #str do
- local val = str:sub(x, x);
- local c = string.byte(val);
- ret = ret..'0x' .. string.format('%02X ', c);
- end
- return ret:trim();
- end
- function _dec2hex(dec) local b,k,r,i,d=16,"0123456789ABCDEF","",0
- while dec>0 do i=i+1 dec,d=math.floor(dec/b),math.mod(dec,b)+1 r=string.sub(k,d,d)..r end
- return r
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement