Skip to content

Commit

Permalink
add farlands support to player api
Browse files Browse the repository at this point in the history
  • Loading branch information
wsor4035 committed Sep 7, 2024
1 parent 3d28f3f commit 0db93b7
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ read_globals = {
"sounds",
"player_api",
"mcl_player",
"fl_player",
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ See the respective sub apis doc file in /doc for detailed documentation.
| MineClone2 | x | x | | x |
| Mineclonia | x | x | | x |
| Hades Revisited | x | x | | |
| Farlands Reloaded | x | x | x | |
| Farlands Reloaded | x | x | x | x |
| Exile | x | | | |
| KSurvive 2 | x | | | |
| Forgotten Lands | x | | | |
Expand Down
2 changes: 1 addition & 1 deletion mod.conf
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, player_api, mcl_player
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
51 changes: 51 additions & 0 deletions src/player/farlands_reloaded.lua
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

0 comments on commit 0db93b7

Please sign in to comment.