Optimize
This commit is contained in:
parent
8152065be8
commit
04cab305b0
@ -1,4 +1,10 @@
|
|||||||
namespace hand {
|
namespace hand {
|
||||||
|
|
||||||
|
const optionWrap = utility.optionWrap;
|
||||||
|
type Option<T> = utility.Option<T>;
|
||||||
|
let warning = utility.warning;
|
||||||
|
|
||||||
|
|
||||||
utility.registerNode("hand", {
|
utility.registerNode("hand", {
|
||||||
tiles: ["character.png"],
|
tiles: ["character.png"],
|
||||||
visual_scale: 1,
|
visual_scale: 1,
|
||||||
@ -9,15 +15,17 @@ namespace hand {
|
|||||||
})
|
})
|
||||||
|
|
||||||
minetest.register_on_joinplayer((player: ObjectRef, _: string) => {
|
minetest.register_on_joinplayer((player: ObjectRef, _: string) => {
|
||||||
|
|
||||||
// If the player's inventory disappears, uh oh.
|
// If the player's inventory disappears, uh oh.
|
||||||
utility.optionWrap<InvRef>(player.get_inventory())
|
let result: Option<InvRef> = optionWrap<InvRef>(player.get_inventory());
|
||||||
.someFunction((inv: InvRef) => {
|
switch (result.is_some()) {
|
||||||
|
case true: {
|
||||||
|
const inv = result.unwrap();
|
||||||
inv.set_size("hand", 1);
|
inv.set_size("hand", 1);
|
||||||
inv.set_stack("hand", 1, "hand");
|
inv.set_stack("hand", 1, "hand");
|
||||||
})
|
}
|
||||||
.noneFunction(() => {
|
case false: {
|
||||||
utility.warning("Player inventory disappeared when creating the 3D hand!");
|
warning("Player inventory disappeared when creating the 3D hand!");
|
||||||
})
|
}
|
||||||
});
|
}
|
||||||
|
})
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user