• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

blockexchange / blockexchange / 13110168475

03 Feb 2025 09:18AM UTC coverage: 48.213% (+0.6%) from 47.564%
13110168475

push

github

BuckarooBanzay
http/json overhaul

51 of 102 new or added lines in 14 files covered. (50.0%)

1 existing line in 1 file now uncovered.

985 of 2043 relevant lines covered (48.21%)

1734.77 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

3.51
/commands/allocate.lua
1

2
-- list of builtin mods
3
local builtin_mods = {
1✔
4
  air = true
×
5
}
6

7
local function get_missing_mods(mods)
8
  -- collect missing mods in a list
9
  local missing_mods = ""
×
10
  for _, modname in ipairs(mods) do
×
11
    if not builtin_mods[modname] and not minetest.get_modpath(modname) then
×
12
      if #missing_mods > 0 then
×
13
        -- add comma separator
14
        missing_mods = missing_mods .. ","
×
15
      end
16
      missing_mods = missing_mods .. modname
×
17
    end
18
  end
19

20
  return missing_mods
×
21
end
22

23
function blockexchange.allocate(playername, pos1, username, schemaname, local_load)
2✔
24
  local promise = Promise.new()
×
25

26
  if local_load then
×
27
    -- local operation
28
    local filename = blockexchange.get_local_filename(schemaname)
×
29
    local f = io.open(filename, "rb")
×
30
    if not f then
×
31
      promise:reject("file not found: " .. filename)
×
32
      return promise
×
33
    end
34
    local z, err_msg = mtzip.unzip(f)
×
35
    if err_msg then
×
36
      promise:reject("unzip error: " .. err_msg)
×
37
      return promise
×
38
    end
39

40
    local schema_str
41
    schema_str, err_msg = z:get("schema.json", true)
×
42
    if err_msg then
×
43
      promise:reject("schema.json error: " .. err_msg)
×
44
      return promise
×
45
    end
46
    local schema = minetest.parse_json(schema_str)
×
47
    if not schema then
×
48
      promise:reject("Schema not found: '" .. schemaname .. "'")
×
49
      return
×
50
    end
51
                local pos2 = vector.add(pos1, blockexchange.get_schema_size(schema))
×
52
    pos2 = vector.subtract(pos2, 1)
×
53

54
    blockexchange.set_pos(2, playername, pos2)
×
55

56
    local mods_str
57
    mods_str, err_msg = z:get("mods.json")
×
58
    if err_msg then
×
59
      promise:reject("mods.json error: " .. err_msg)
×
60
      return promise
×
61
    end
62
    f:close()
×
63

64
    local mods = minetest.parse_json(mods_str)
×
65
    local missing_mods = get_missing_mods(mods)
×
66

67
    promise:resolve({
×
68
      schema = schema,
69
      missing_mods = missing_mods
×
70
    })
71
  else
72
    -- online
73
    blockexchange.api.get_schema_by_name(username, schemaname, false):next(function(schema)
×
74
      if not schema then
×
75
        promise:reject("Schema not found: '" .. username .. "/" .. schemaname .. "'")
×
76
        return
×
77
      end
78
      local pos2 = vector.add(pos1, blockexchange.get_schema_size(schema))
×
79
      pos2 = vector.subtract(pos2, 1)
×
80
      blockexchange.set_pos(2, playername, pos2)
×
81

82
      blockexchange.api.get_schemamods(schema.uid):next(function(mods)
×
83
        local missing_mods = get_missing_mods(mods)
×
84
        promise:resolve({
×
85
          schema = schema,
86
          missing_mods = missing_mods
×
87
        })
NEW
88
      end):catch(function(err)
×
NEW
89
        local err_msg = "[blockexchange] get schemamods failed: " .. (err or "unkown")
×
90
        minetest.log("error", err_msg)
×
91
        promise:reject(err_msg)
×
92
      end)
93
    end)
94
  end
95

96
  return promise
×
97
end
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc