Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new handler.lua + base LuaIntro enviroment with a few examples
new handler.lua is just used for LuaIntro, technically it's ready for LuaUI too but it would break a few widgets (that did dirty things on the old handler), so I want to give games a bit more time to fix those
- Loading branch information
jK
committed
Jul 7, 2013
1 parent
5b894df
commit 3b2483a
Showing
27 changed files
with
4,657 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
cont/base/springcontent/LuaHandler/SystemAddons/watchdog.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
|
||
if addon.InGetInfo then | ||
return { | ||
name = "Watchdog"; | ||
desc = ""; | ||
version = 0.1; | ||
author = "jK"; | ||
date = "2013"; | ||
license = "GNU GPL, v2 or later"; | ||
|
||
layer = math.huge; | ||
hidden = not true; -- don't show in the widget selector | ||
api = true; -- load before all others? | ||
|
||
enabled = not true; -- loaded by default? | ||
} | ||
end | ||
|
||
|
||
local i=0 | ||
local function hook(event) | ||
i = i + 1 | ||
if ((i % (10^4)) < 1) then | ||
i = 0 | ||
Spring.Echo(Spring.GetGameFrame(), event, debug.getinfo(2).name) | ||
Spring.Echo(debug.traceback()) | ||
end | ||
end | ||
|
||
|
||
function addon.Initialize() | ||
debug.sethook(hook,"r",10^100) | ||
end | ||
|
||
|
||
function addon.Shutdown() | ||
debug.sethook(nil,"r") | ||
end |
42 changes: 42 additions & 0 deletions
42
cont/base/springcontent/LuaHandler/Utilities/VFS_GetFileChecksum.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-------------------------------------------------------------------------------- | ||
-------------------------------------------------------------------------------- | ||
-- | ||
-- file: VFS_GetFileChecksum.lua | ||
-- brief: | ||
-- author: jK | ||
-- | ||
-- Copyright (C) 2007-2013. | ||
-- Licensed under the terms of the GNU GPL, v2 or later. | ||
-- | ||
-------------------------------------------------------------------------------- | ||
-------------------------------------------------------------------------------- | ||
|
||
if (not VFS.GetFileChecksum) then | ||
function VFS.GetFileChecksum(file, _VFSMODE) | ||
local data = VFS.LoadFile(file, _VFSMODE) | ||
if (data) then | ||
local datalen = data:len()/4 --// 'x/4' cause we use UnpackU32 | ||
local striplength = 2 * 1024 --// 2kB | ||
|
||
if (striplength >= datalen) then | ||
local bytes = VFS.UnpackU32(data,nil,datalen) | ||
local checksum = math.bit_xor(0,unpack(bytes)) | ||
return checksum | ||
end | ||
|
||
--// stack is limited, so split up the data | ||
local start = 1 | ||
local crcs = {} | ||
repeat | ||
local strip = data:sub(start,start+striplength) | ||
local bytes = VFS.UnpackU32(strip,nil,strip:len()/4) | ||
local checksum = math.bit_xor(0,unpack(bytes)) | ||
crcs[#crcs+1] = checksum | ||
start = start + striplength | ||
until (start >= datalen) | ||
|
||
local checksum = math.bit_xor(0,unpack(crcs)) | ||
return checksum | ||
end | ||
end | ||
end |
Oops, something went wrong.
3b2483a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awesome, we have a progress bar! 👯
3b2483a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can LuaIntro be reused for a custom menu?
thats what the setting "MenuArchive" is meant for, too..
also it seems to use "description" from modinfo.lua, shouldn't it use "name"?
for BA it shows "Moooooo!": http://imolarpg.dyndns.org/trac/balatest/browser/trunk/modinfo.lua
for zk its ok: http://code.google.com/p/zero-k/source/browse/trunk/mods/zk/modinfo.lua
3b2483a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| can LuaIntro be reused for a custom menu?
that's why it is named LuaIntro and not LuaLoadscreen
there are no callins for such yet, would need a lot work to get that (first a callout that accepts map & script.txt to start spring similar to Spring.Restart() just w/o restart, new callouts to iterate available maps & ais, and maybe a callout to get the minimap of arbitrary maps).
3b2483a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mehhhh
Game.modDesc cause I wanted "Zero-K" without (!) version appendix, engine seems to miss such one then ....