-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
58 additions
and
55 deletions.
There are no files selected for viewing
Submodule maps
updated
7 files
+ − | mayan_legend/map.mts | |
+21 −0 | race_day/map.conf | |
+ − | race_day/map.mts | |
+ − | race_day/screenshot.png | |
+21 −0 | savanna_ravine/map.conf | |
+ − | savanna_ravine/map.mts | |
+ − | savanna_ravine/screenshot.png |
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
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 |
---|---|---|
@@ -1,57 +1,57 @@ | ||
return function(top) | ||
local modstorage = assert(minetest.get_mod_storage(), "Can only init rankings at runtime!") | ||
local modstorage = assert(minetest.get_mod_storage(), "Can only init rankings at runtime!") | ||
|
||
for k, v in pairs(modstorage:to_table()["fields"]) do | ||
local rank = minetest.parse_json(v) | ||
if rank ~= nil and rank.score then | ||
top:set(k, rank.score) | ||
end | ||
for k, v in pairs(modstorage:to_table()["fields"]) do | ||
local rank = minetest.parse_json(v) | ||
if rank ~= nil and rank.score then | ||
top:set(k, rank.score) | ||
end | ||
end | ||
|
||
return { | ||
backend = "default", | ||
top = top, | ||
modstorage = modstorage, | ||
|
||
get = function(self, pname) | ||
pname = PlayerName(pname) | ||
return { | ||
backend = "default", | ||
top = top, | ||
modstorage = modstorage, | ||
|
||
local rank_str = self.modstorage:get_string(pname) | ||
get = function(self, pname) | ||
pname = PlayerName(pname) | ||
|
||
if not rank_str or rank_str == "" then | ||
return false | ||
end | ||
local rank_str = self.modstorage:get_string(pname) | ||
|
||
return minetest.parse_json(rank_str) | ||
end, | ||
set = function(self, pname, newrankings, erase_unset) | ||
pname = PlayerName(pname) | ||
if not rank_str or rank_str == "" then | ||
return false | ||
end | ||
|
||
if not erase_unset then | ||
local rank = self:get(pname) | ||
if rank then | ||
for k, v in pairs(newrankings) do | ||
rank[k] = v | ||
end | ||
return minetest.parse_json(rank_str) | ||
end, | ||
set = function(self, pname, newrankings, erase_unset) | ||
pname = PlayerName(pname) | ||
|
||
newrankings = rank | ||
if not erase_unset then | ||
local rank = self:get(pname) | ||
if rank then | ||
for k, v in pairs(newrankings) do | ||
rank[k] = v | ||
end | ||
end | ||
|
||
self.top:set(pname, newrankings.score or 0) | ||
self.modstorage:set_string(pname, minetest.write_json(newrankings)) | ||
end, | ||
add = function(self, pname, amounts) | ||
pname = PlayerName(pname) | ||
newrankings = rank | ||
end | ||
end | ||
|
||
local newrankings = self:get(pname) or {} | ||
self.top:set(pname, newrankings.score or 0) | ||
self.modstorage:set_string(pname, minetest.write_json(newrankings)) | ||
end, | ||
add = function(self, pname, amounts) | ||
pname = PlayerName(pname) | ||
|
||
for k, v in pairs(amounts) do | ||
newrankings[k] = (newrankings[k] or 0) + v | ||
end | ||
local newrankings = self:get(pname) or {} | ||
|
||
self.top:set(pname, newrankings.score or 0) | ||
self.modstorage:set_string(pname, minetest.write_json(newrankings)) | ||
for k, v in pairs(amounts) do | ||
newrankings[k] = (newrankings[k] or 0) + v | ||
end | ||
} | ||
|
||
self.top:set(pname, newrankings.score or 0) | ||
self.modstorage:set_string(pname, minetest.write_json(newrankings)) | ||
end | ||
} | ||
end |