Coder Social home page Coder Social logo

danielga / luapack Goto Github PK

View Code? Open in Web Editor NEW
35.0 12.0 4.0 83 KB

A system for Garry's Mod that provides Lua files to clients in a more efficient way. WIP

Home Page: https://danielga.github.io/luapack

License: Other

Lua 100.00%
garrysmod gmod garrys-mod lua garrysmod-addon gmod-addon gmodaddon gmodlua gmod-lua

luapack's Introduction

LuaPack

A Garry's Mod addon that attempts to speed up Lua files downloading by compressing and packing them.

Info

garrysmod/lua/send.txt must be renamed to garrysmod/lua/_send.txt

garrysmod/lua/includes/init.lua must be renamed to garrysmod/lua/includes/_init.lua

This addon requires the gmsv_luapack_internal module.

luapack's People

Contributors

danielga avatar python1320 avatar

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

Watchers

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

luapack's Issues

Reduce binary modules dependencies

luaiox is a dangerous module which opens up a nest of very nasty stuff.
crypt is nice and all but is very bulky and has way too many features we don't use.
With an internal module we could group all the required features together like CRC32 (GMod already has this but I don't trust its performance and how we're forced to push all data at once, which can be quite big on Lua files), SHA-1, file writing and required detours for AddCSLuaFile.

Improve pack file structure

Include a version number on each pack file so the appropriate protocol is called on the decoder.
Handle files that are changed rather frequently or some similar system (based on signatures?).

Module not found

Hello

After successful compilation (windows) gmod says ' module not found ' ( sv_core.lua:25)
but gmsv_luapack_internal_win32 is in lua/bin

Is it still working in 2018?

Improve pack file creation times

Currently, the pack files on Metastruct takes between 8 to 20 seconds (how they vary so much, I don't know) but usually take around 10 seconds. They are compressed and packed. Maybe don't compress in Lua at all and use an internal binary module to do this with threads?

Some Lua files are not run successfully

Hello again :)
Transferring the issue from: danielga/gmsv_luapack_internal#7
Something is wrong with mounting files from the pack. I tried to debug it a bit, looks like some files are mounting but init fails and ents / vgui, everything is broken.

Server:
image

Client:
image
Pack successfully downloaded.

Broken init:
image
image

Captured on windows, server files are clean.

workshop issue

when your server forces clients to download map from workshop, you get kicked for missing map because it skips the workshop loading thing and starts to search for the map in fastdl

debug.getregistry fix inside includes/init.lua

i'm sure you knew but rubat destroyed debug.getregistry, and appended a temporary fix to includes/init.lua

Here's my version of the fix, and below that is his version.

local _R

OldFindMetaTable = OldFindMetaTable or FindMetaTable
function FindMetaTable(name)
	return name and _R[name] or nil
end

do
	_R = setmetatable({
		[1] = function() end,
		[2] = _G,
		[3] = {},
	}, {
		__index = function(obj, key)
			local tab = key and oldFindMetaTable(key)
			if rawget(obj, key) then
				return rawget(obj, key)
			elseif tab then
				obj[key] = tab
				return tab
			else
				return nil
			end
		end
	})
end

function debug.getregistry()
	return _R
end
-- Temporary hack
local meta = {}
function meta.__index(self, key)
	return FindMetaTable(key)
end

local metas = {}
function meta.__newindex(self, key, value)
	metas[ key ] = value
end

debug.getregistry = function()
	local tbl = {}
	setmetatable(tbl, meta)

	return tbl
end

local oldFindMetaTable = FindMetaTable
FindMetaTable = function( name )
	local f = oldFindMetaTable( name )
	if ( f ) then return f end

	return metas[ name ]
end

"include" does not return a value

function include(filepath)
local time = SysTime()
local obj = GetFileFromPathStack(filepath)
if obj ~= nil then
CompileString(obj:GetContents(), obj:GetFullPath())()
luapack.AddTime(SysTime() - time)
return
end
luapack.DebugMsg("Couldn't include Lua file from luapack, proceeding with normal include", filepath)
luapack.include(filepath)
luapack.AddTime(SysTime() - time)
end


Wiki

https://wiki.facepunch.com/gmod/Global.include


Expected

The result of the script execution (vararg)


Now

Just compiles the code, and does not return the compilation result. There is a chance to break scripts that are dependent on the result of execution. For example:

local BaseClass = include('mod_core/classes/base_class.lua')

Engine Error

keep trying to install this to my sandbox server and this keeps poping up other than that it seems to be working fine besides crashing upon join, after i remove the luapack stuff the server works fine off of the workshop dl.

Screenshot 2023-10-26 182700

Screenshot 2023-10-26 182829

Failed to open pack file

[ERROR] addons/luapack/lua/luapack/cl_core.lua:71: failed to open pack file 'download/data/luapack/D4AE9D00F4AE58093E883DEE61928D7A696F2B13.dat' for reading
  1. error - [C]:-1
   2. BuildFileList - addons/luapack/lua/luapack/cl_core.lua:71
    3. unknown - addons/luapack/lua/luapack/cl_core.lua:95
     4. include - [C]:-1
      5. unknown - addons/luapack/lua/includes/init.lua:11

I got this error upon join. It created the file on the server, but it isn't in the mentioned folder on the client. There's no console error before this one.

Failed client init

Hello

I'm fighting with this sice first time opened an issue for luapack :/
Everything is set correctly for sure.

When I connect to server, everytime init fails:

[LuaPack] Found the current pack file hash ('313C9C317B2A3E9E49AEDA1B2754D5A8309A5D2A')!
[LuaPack] Starting Lua file list build of 'download/data/luapack/313C9C317B2A3E9E49AEDA1B2754D5A8309A5D2A.dat'!

[ERROR] lua/luapack/cl_directory.lua:177: attempt to get length of local 'list' (a nil value)

  1. GetIterator - lua/luapack/cl_directory.lua:177
  2. GetSingle - lua/luapack/cl_directory.lua:156
    3. AddFile - lua/luapack/cl_directory.lua:73
    4. BuildFileList - lua/luapack/cl_core.lua:83
    5. unknown - lua/luapack/cl_core.lua:95
    6. include - [C]:-1
    7. unknown - lua/includes/init.lua:9

Couldn't include file 'derma\init.lua' (File not found) ()
Couldn't include file 'includes\modules\notification.lua' (File not found) (@startup (line 1))

-----> and spam of errors here, everything no value, client init totaly dead.

I have no more ideas, tried everything.

๐ŸŒต

Server and client files are clean, no serverside errors.

Issue when used along side Server Secure (I believe could be related to finding a file)

Error Recieved:
`[ERROR] gamemodes/darkrp/gamemode/init.lua:16: attempt to index global 'serversecure' (a nil value)

  1. v - gamemodes/darkrp/gamemode/init.lua:16
  2. unknown - addons/plib_v2/lua/plib/libraries/hook.lua:25
    `

Other then that issue showing up server starts up perfectly with no other lua error except for when a GM hook tries to use a function inside serversecure. Other modules such as tmysql work perfectly fine however serverside.

On joining the server tho I have several files that are trying to be included in various places that are showing up as 'file not found'

My guess is some how not being able to properly recognize where the files are located?

Other then this I don't know what other information to give besides that I have verified that the send.txt is renamed to _sent.txt, the default lua/includes/init.lua is renamed to _init.lua and the serversecure.lua is in lua/includes/modules/ where it should be.

I hope this information is somewhat useful.

p.s. Thank you for the work you've done with these amazing modules

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.