mirror of
https://github.com/mt-mods/xcompat.git
synced 2025-11-20 17:45:27 +01:00
Add explanations of textures & player api usage, non-function sounds, and some minor touch-up of docs (#55)
This commit is contained in:
@@ -1,13 +1,21 @@
|
||||
# Player API
|
||||
|
||||
mimic mtg player_api
|
||||
## Usage
|
||||
|
||||
## NOTE
|
||||
The player api can be accessed in your script through `xcompat.player`.
|
||||
|
||||
`xcompat.player.player_attached`
|
||||
This object mimics the `player_api` from Minetest Game, and should be a drop-in
|
||||
replacement in most cases. You should be able to simply replace instances
|
||||
of `player_api` in your script with `xcompat.player`.
|
||||
|
||||
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
|
||||
|
||||
## Note on `xcompat.player.player_attached`
|
||||
|
||||
Reading & writing to this object works, but because it's a proxy table it can't
|
||||
be looped over.
|
||||
|
||||
Looping over this object would require lua5.2 `__pairs`/`__ipairs` metamethod support.
|
||||
It would be possible to implement support for this through polyfill,
|
||||
using [this method](https://stackoverflow.com/a/77354254)
|
||||
(luajit supports this via 5.2 extensions), but it's not implemented as of now.
|
||||
Additionally see [this engine issue](https://github.com/minetest/minetest/issues/15133).
|
||||
|
||||
Reference in New Issue
Block a user