Compare commits
6 Commits
7eb5f09752
...
597666f3e3
Author | SHA1 | Date |
---|---|---|
Lars Mueller | 597666f3e3 | |
Lars Mueller | 318e737a08 | |
Lars Mueller | b7c6514bc8 | |
Lars Müller | 017f2119cb | |
NobWow | 9f65d5df9a | |
Lars Mueller | 234f6d1ecd |
|
@ -4,7 +4,7 @@ Multipurpose Minetest Modding Library
|
|||
|
||||
## About
|
||||
|
||||
No dependencies. Licensed under the MIT License. Written by Lars Mueller aka LMD or appguru(eu). Notable contributions by [luk3yx](https://github.com/luk3yx) in the form of suggestions, bug reports and fixes.
|
||||
No dependencies. Licensed under the MIT License. Written by Lars Mueller aka LMD or appguru(eu). Notable contributions by [luk3yx](https://github.com/luk3yx) in the form of suggestions, bug reports and fixes. Another [bugfix](https://github.com/appgurueu/modlib/pull/7) by [NobWow](https://github.com/NobWow/).
|
||||
|
||||
## Tests
|
||||
|
||||
|
@ -421,4 +421,4 @@ Fixes, minor additions (such as a `hashheap`)
|
|||
* Fixes `math.fround`
|
||||
* Other minor fixes
|
||||
* Switch to lazy loading
|
||||
* Do `_ = modlib.<module>` to avoid lag spikes at run time
|
||||
* Do `_ = modlib.<module>` to avoid lag spikes at run time
|
||||
|
|
7
file.lua
7
file.lua
|
@ -121,11 +121,8 @@ end
|
|||
function process_bridge_listen(name, line_consumer, step)
|
||||
local bridge = process_bridges[name]
|
||||
modlib.minetest.register_globalstep(step or 0.1, function()
|
||||
local content = io.open(bridge.input, "r")
|
||||
local line = content:read()
|
||||
while line do
|
||||
for line in io.lines(bridge.input) do
|
||||
line_consumer(line)
|
||||
line = content:read()
|
||||
end
|
||||
write(bridge.input, "")
|
||||
end)
|
||||
|
@ -150,4 +147,4 @@ function process_bridge_start(name, command, os_execute)
|
|||
end
|
||||
|
||||
-- Export environment
|
||||
return _ENV
|
||||
return _ENV
|
||||
|
|
|
@ -240,6 +240,7 @@ function ptab:rewrite()
|
|||
end
|
||||
|
||||
function ptab:set(table, key, value)
|
||||
exec(self, "BEGIN EXCLUSIVE TRANSACTION")
|
||||
local previous_value = table[key]
|
||||
if previous_value == value then
|
||||
-- no change
|
||||
|
@ -247,6 +248,7 @@ function ptab:set(table, key, value)
|
|||
end
|
||||
set(self, table, key, value)
|
||||
table[key] = value
|
||||
exec(self, "COMMIT TRANSACTION")
|
||||
end
|
||||
|
||||
function ptab:set_root(key, value)
|
||||
|
|
16
text.lua
16
text.lua
|
@ -62,13 +62,17 @@ function trim_spacing(text)
|
|||
end
|
||||
|
||||
local inputstream_metatable = {
|
||||
__index = {read = function(self, count)
|
||||
local cursor = self.cursor + 1
|
||||
self.cursor = self.cursor + count
|
||||
local text = self.text:sub(cursor, self.cursor)
|
||||
return text ~= "" and text or nil
|
||||
end}
|
||||
__index = {
|
||||
read = function(self, count)
|
||||
local cursor = self.cursor + 1
|
||||
self.cursor = self.cursor + count
|
||||
local text = self.text:sub(cursor, self.cursor)
|
||||
return text ~= "" and text or nil
|
||||
end,
|
||||
seek = function(self) return self.cursor end
|
||||
}
|
||||
}
|
||||
--> inputstream "handle"; only allows reading characters (given a count), seeking does not accept any arguments
|
||||
function inputstream(text)
|
||||
return setmetatable({text = text, cursor = 0}, inputstream_metatable)
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue