mirror of
https://github.com/minetest/minetest.git
synced 2024-11-26 17:43:45 +01:00
Add shorthand form for touch_interaction
This commit is contained in:
parent
8935f2af3c
commit
e79587c934
@ -9095,20 +9095,20 @@ Used by `minetest.register_node`, `minetest.register_craftitem`, and
|
||||
-- Otherwise should be name of node which the client immediately places
|
||||
-- upon digging. Server will always update with actual result shortly.
|
||||
|
||||
touch_interaction = {
|
||||
-- Only affects touchscreen clients.
|
||||
-- Defines the meaning of short and long taps with the item in hand.
|
||||
-- The fields in this table can be set to the following values:
|
||||
-- * "user" (meaning depends on client-side settings)
|
||||
-- * "long_dig_short_place" (long tap = dig, short tap = place)
|
||||
-- * "short_dig_long_place" (short tap = dig, long tap = place)
|
||||
-- The field to be used is selected according to the current
|
||||
-- `pointed_thing`.
|
||||
|
||||
pointed_nothing = "user",
|
||||
pointed_node = "user",
|
||||
pointed_object = "user",
|
||||
touch_interaction = <TouchInteractionMode> OR {
|
||||
pointed_nothing = <TouchInteractionMode>,
|
||||
pointed_node = <TouchInteractionMode>,
|
||||
pointed_object = <TouchInteractionMode>,
|
||||
},
|
||||
-- Only affects touchscreen clients.
|
||||
-- Defines the meaning of short and long taps with the item in hand.
|
||||
-- If specified as a table, the field to be used is selected according to
|
||||
-- the current `pointed_thing`.
|
||||
-- There are three possible TouchInteractionMode values:
|
||||
-- * "user" (meaning depends on client-side settings)
|
||||
-- * "long_dig_short_place" (long tap = dig, short tap = place)
|
||||
-- * "short_dig_long_place" (short tap = dig, long tap = place)
|
||||
-- The default value is "user".
|
||||
|
||||
sound = {
|
||||
-- Definition of item sounds to be played at various events.
|
||||
|
@ -156,17 +156,24 @@ void read_item_definition(lua_State* L, int index,
|
||||
|
||||
getboolfield(L, index, "wallmounted_rotate_vertical", def.wallmounted_rotate_vertical);
|
||||
|
||||
TouchInteraction &inter = def.touch_interaction;
|
||||
lua_getfield(L, index, "touch_interaction");
|
||||
if (!lua_isnil(L, -1)) {
|
||||
luaL_checktype(L, -1, LUA_TTABLE);
|
||||
|
||||
TouchInteraction &inter = def.touch_interaction;
|
||||
if (lua_istable(L, -1)) {
|
||||
inter.pointed_nothing = (TouchInteractionMode)getenumfield(L, -1, "pointed_nothing",
|
||||
es_TouchInteractionMode, inter.pointed_nothing);
|
||||
inter.pointed_node = (TouchInteractionMode)getenumfield(L, -1, "pointed_node",
|
||||
es_TouchInteractionMode, inter.pointed_node);
|
||||
inter.pointed_object = (TouchInteractionMode)getenumfield(L, -1, "pointed_object",
|
||||
es_TouchInteractionMode, inter.pointed_object);
|
||||
} else if (lua_isstring(L, -1)) {
|
||||
int value;
|
||||
if (string_to_enum(es_TouchInteractionMode, value, lua_tostring(L, -1))) {
|
||||
inter.pointed_nothing = (TouchInteractionMode)value;
|
||||
inter.pointed_node = (TouchInteractionMode)value;
|
||||
inter.pointed_object = (TouchInteractionMode)value;
|
||||
}
|
||||
} else if (!lua_isnil(L, -1)) {
|
||||
throw LuaError("invalid type for 'touch_interaction'");
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user