Giter VIP home page Giter VIP logo

roblox-library's Introduction

Roblox library

This repository contains various modules, scripts, and snippets for use on Roblox. Maybe you'll find something useful.

It is expected that code will be taken and adapted to suit the user's needs. As such, files are not versioned, and APIs can change at any time. To find previous revisions of a file, search the commit history.

Code in this repository is licensed under MIT-0. Contributions will not be accepted, but suggestions are welcome.

Directories

Files within this repository are divided into a number of directories.

documents

Contains non-script files of interest.

modules

Each subdirectory contains the source code of a ModuleScript. May also contain a few other files:

  • A README file describing the API of the module, generated from the module source using qdoc.
  • A .test.lua file that tests the module using the Testing module. Test runners may be generated automatically with the test.rbxmk.lua script.

A module may require another module in this repository. This is done by assuming the two modules are siblings (require(script.Parent.Module)). Such lines may have to be adjusted as needed.

Modules are not necessarily production ready.

plugins

Each subdirectory contains a plugin for use in Roblox Studio. A plugin here can be installed by copying the subdirectory to Studio's configured plugins folder.

snippets

Contains shorter snippets of code that may be incorporated into the source of a larger script.

roblox-library's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

roblox-library's Issues

use bit32 in base85.decode -> speed

Hello, what you use on base85.decode looks like using math.floor to extract bits from numbers.
You can use bit32.extract instead to gain some speedup (and bit32.rshift for the first byte)

BEFORE: 2.691, 2.701, 2.694, 2.706, 2.708
AFTER: 2.444, 2.436, 2.440, 2.446, 2.438

total speedup: 10.5%

Can't sumbit a PR or patch due to Public Domain requirements, though.

IT SUCKS

--[[
	Int64 class that is used to handle integer based
	encoding.
	This can be configured to any type, just make sure it is never over
	32 bits(as it is a limitation of roblox's memory allocator)
	@author JESUS
	@submodule Int64
]]

local Int64 = {};
Int64.__index = Int64;

-- purpose: constructor
function Int64.new(bytes)
	return setmetatable({
		_arr = table.create(bytes,0);
		_number = 0;
		_offset = 0;
		_reading = 1;
	}, Int64);
end

-- purpose: clear int arr
function Int64:clear()
	self._reading=1;
	self._offset=0;
	table.clear(self._arr);
end

-- purpose: read buffer
function Int64:read(buffer)
	self._arr=buffer;
	self._number=buffer[1];
	self._offset=0;
	self._reading=1;
end

-- purpose: to bits
local function toBits(num, bits)
	local t={}; -- will contain the bits
	for b=bits,1,-1 do
		local rest=math.fmod(num,2);
		t[b]=rest;
		num=(num-rest)/2;
	end
	if(num==0)then 
		return t;
	end
end

-- purpose: max bit lol
local max_bits=16;
local max_32_bit=bit32.lshift(1,max_bits)-1;
function Int64:set(amnt, value)
	local remaining=max_bits-self._offset;
	if(self._offset==0 and amnt==max_bits)then
		-- maximum bit count lol
		self._arr[self._reading]=bit32.band(value,max_32_bit);
		self._offset=0;
		self._reading+=1;
		return;
	elseif(remaining>=amnt)then
		-- can fit segment
		self._number=bit32.replace(self._number,value,self._offset,amnt);
		self._offset+=amnt;
		
		-- skip if possible
		if((max_bits-self._offset)==0)then
			self._arr[self._reading]=self._number;
			self._reading+=1;
			self._offset=0;
			self._number=0;
		end
	elseif(remaining==0)then
		-- mike
		self._arr[self._reading]=self._number;
		self._reading+=1;
		self._number=bit32.extract(value,0,amnt);
		self._offset=amnt;
	else
		-- have to split up to multiple segments
		local after=amnt-remaining;
		self._arr[self._reading]=bit32.replace(self._number,value,self._offset,remaining);
		self._number=bit32.rshift(value,remaining);--bit32.extract(value,remaining,after);
		self._offset=after;
		self._reading+=1;
	end
end

-- purpose: get bits lol
function Int64:get(amnt)
	local remaining=max_bits-self._offset;
	if(self._offset==0 and amnt==max_bits)then
		-- maximum bit count lol
		self._offset=0;
		self._reading+=1;
		self._number=self._arr[self._reading];
		return self._arr[self._reading-1];
	elseif(remaining>=amnt)then
		-- can fit segment
		local number=bit32.extract(self._number,self._offset,amnt);
		self._offset+=amnt;

		-- skip if possible
		if((max_bits-self._offset)<=0)then
			self._reading+=1;
			self._number=self._arr[self._reading];
			self._offset=0;
		end
		return number;
	elseif(remaining==0)then
		-- edge segment
		self._reading+=1;
		self._number=self._arr[self._reading];
		self._offset=amnt;
		return bit32.extract(self._number,0,amnt);
	else
		-- have to split up to multiple segments
		self._reading+=1;		
		local after=amnt-remaining;
		local other=self._arr[self._reading];
		local number=bit32.extract(self._number,self._offset,remaining);
		self._offset=after;
		self._number=other;
		return bit32.lshift(bit32.extract(other,0,after),remaining)+number;
	end
end

-- purpose: set segs(yea)
function Int64:setSeg(numSegs, value)
	if(numSegs<=2)then
		self:set(max_bits*numSegs,value);
	else
		-- align reader
		local value=self:set(max_bits-self._offset);
		for i=2,numSegs-1 do
			value=bit32.lshift(value,max_bits)+self._arr[self._reading];
			self._reading+=1;
		end
		return value+self:set(max_bits-self._offset);
	end
end

-- purpose: get num segs(yea)
function Int64:getSeg(num)
	if(num<=2)then
		-- no need to align for this one
		return self:get(max_bits*num);
	else
		-- align reader
		local value=self:get(max_bits-self._offset);
		for i=2,num-1 do
			value=bit32.lshift(value,max_bits)+self._arr[self._reading];
			self._reading+=1;
		end
		return value+self:get(max_bits-self._offset);
	end
end

-- purpose: dispose
function Int64:dispose()
	table.insert(self._arr,self._number);
	return self._arr;
end

return Int64;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.