-
Notifications
You must be signed in to change notification settings - Fork 5
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
10 changed files
with
210 additions
and
12 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,7 @@ read_globals = { | |
"rp_sounds", | ||
"mtt", | ||
"sounds", | ||
"player_api", | ||
"mcl_player", | ||
"fl_player", | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Player API | ||
|
||
mimic mtg player_api | ||
|
||
## NOTE | ||
|
||
`xcompat.player.player_attached` | ||
|
||
read/write from it is fine, looping over it is not as it is a proxy table. this | ||
would need lua5.2 __pairs/__ipairs metamethods support which i could polyfill | ||
for using https://stackoverflow.com/a/77354254 but didnt feel like doing at | ||
this time. (luajit supports this via 5.2 extensions). additionally see issue: | ||
https://github.com/minetest/minetest/issues/15133 |
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,3 +1,3 @@ | ||
name = xcompat | ||
description = Provides cross compatibility between mods and games for sounds and crafting materials. | ||
optional_depends = default, fl_stone, fl_trees, mcl_sounds, hades_sounds, ks_sounds, nodes_nature, fl_topsoil, fl_trees, mcl_core, farming, x_farming, sounds, mtt | ||
optional_depends = default, fl_stone, fl_trees, mcl_sounds, hades_sounds, ks_sounds, nodes_nature, fl_topsoil, fl_trees, mcl_core, farming, x_farming, sounds, mtt, player_api, mcl_player, fl_player |
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,8 @@ | ||
local filename = xcompat.gameid | ||
|
||
--if we dont have a player file for the game, use minetest | ||
if not xcompat.utilities.file_exists(xcompat.modpath .. "/src/player/" .. filename .. ".lua") then | ||
filename = "xcompat_agnostic" | ||
end | ||
|
||
return dofile(xcompat.modpath .. "/src/player/" .. filename .. ".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,51 @@ | ||
local papi = {} | ||
|
||
local models = {} | ||
function papi.register_model(name, def) | ||
models[name] = def | ||
end | ||
|
||
function papi.set_model(player, model_name) | ||
local model = models[model_name] | ||
|
||
if not model then return end | ||
|
||
player:set_properties({ | ||
mesh = model_name, | ||
textures = model.textures, | ||
visual = "mesh", | ||
visual_size = model.visual_size, | ||
stepheight = model.stepheight | ||
}) | ||
end | ||
|
||
function papi.get_animation(_) | ||
--stub to keep from crashing | ||
end | ||
|
||
function papi.get_textures(player) | ||
return player:get_properties().textures | ||
end | ||
|
||
function papi.set_textures(player, textures) | ||
player:set_properties({textures = textures}) | ||
end | ||
|
||
function papi.set_animation(player, anim_name, speed, loop) | ||
player:set_animation(fl_player.animations[anim_name], speed, 0, loop) | ||
end | ||
|
||
local metatable = { | ||
__index = function (_, key) | ||
return fl_player.ignore[key] | ||
end, | ||
__newindex = function (_, key, value) | ||
rawset(fl_player.ignore, key, value) | ||
end | ||
} | ||
|
||
papi.player_attached = {} | ||
|
||
setmetatable(papi.player_attached, metatable) | ||
|
||
return papi |
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,40 @@ | ||
local papi = {} | ||
|
||
function papi.register_model(name, def) | ||
return mcl_player.player_register_model(name, def) | ||
end | ||
|
||
function papi.set_model(player, model) | ||
return mcl_player.player_set_model(player, model) | ||
end | ||
|
||
function papi.get_animation(player) | ||
return mcl_player.player_get_animation(player) | ||
end | ||
|
||
function papi.get_textures(player) | ||
return player:get_properties().textures | ||
end | ||
|
||
function papi.set_textures(player, textures) | ||
player:set_properties({textures = textures}) | ||
end | ||
|
||
function papi.set_animation(player, anim_name, speed, _) | ||
return mcl_player.player_set_animation(player, anim_name, speed) | ||
end | ||
|
||
local metatable = { | ||
__index = function (_, key) | ||
return mcl_player.player_attached[key] | ||
end, | ||
__newindex = function (_, key, value) | ||
rawset(mcl_player.player_attached, key, value) | ||
end | ||
} | ||
|
||
papi.player_attached = {} | ||
|
||
setmetatable(papi.player_attached, metatable) | ||
|
||
return papi |
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,41 @@ | ||
local papi = {} | ||
|
||
function papi.register_model(name, def) | ||
return player_api.register_model(name, def) | ||
end | ||
|
||
function papi.set_model(player, model) | ||
return player_api.set_model(player, model) | ||
end | ||
|
||
function papi.get_animation(player) | ||
return player_api.get_animation(player) | ||
end | ||
|
||
function papi.get_textures(player) | ||
return player_api.get_textures(player) | ||
end | ||
|
||
function papi.set_textures(player, texture) | ||
return player_api.set_textures(player, texture) | ||
end | ||
|
||
function papi.set_animation(player, anim_name, speed, loop) | ||
return player_api.set_animation(player, anim_name, speed, loop) | ||
end | ||
|
||
|
||
local metatable = { | ||
__index = function (_, key) | ||
return player_api.player_attached[key] | ||
end, | ||
__newindex = function (_, key, value) | ||
rawset(player_api.player_attached, key, value) | ||
end | ||
} | ||
|
||
papi.player_attached = {} | ||
|
||
setmetatable(papi.player_attached, metatable) | ||
|
||
return papi |
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,41 @@ | ||
local papi = {} | ||
|
||
local models = {} | ||
function papi.register_model(name, def) | ||
models[name] = def | ||
end | ||
|
||
function papi.set_model(player, model_name) | ||
local model = models[model_name] | ||
|
||
if not model then return end | ||
|
||
player:set_properties({ | ||
mesh = model_name, | ||
textures = model.textures, | ||
visual = "mesh", | ||
visual_size = model.visual_size, | ||
stepheight = model.stepheight | ||
}) | ||
end | ||
|
||
function papi.get_animation(_) | ||
--stub to keep from crashing | ||
end | ||
|
||
function papi.get_textures(player) | ||
return player:get_properties().textures | ||
end | ||
|
||
function papi.set_textures(player, textures) | ||
player:set_properties({textures = textures}) | ||
end | ||
|
||
function papi.set_animation(_, _, _, _) | ||
--stub to keep from crashing | ||
end | ||
|
||
--nothing to do here as we have no globalstep .....that we know about anyways | ||
papi.player_attached = {} | ||
|
||
return papi |