diff --git a/rts/Lua/LuaUnsyncedCtrl.cpp b/rts/Lua/LuaUnsyncedCtrl.cpp index d447aa5c9b..ef63f62fa3 100644 --- a/rts/Lua/LuaUnsyncedCtrl.cpp +++ b/rts/Lua/LuaUnsyncedCtrl.cpp @@ -312,6 +312,7 @@ bool LuaUnsyncedCtrl::PushEntries(lua_State* L) REGISTER_LUA_CFUNC(SetGroundDecalQuadPosAndHeight); REGISTER_LUA_CFUNC(SetGroundDecalRotation); REGISTER_LUA_CFUNC(SetGroundDecalTexture); + REGISTER_LUA_CFUNC(SetGroundDecalTextureParams); REGISTER_LUA_CFUNC(SetGroundDecalAlpha); REGISTER_LUA_CFUNC(SetGroundDecalNormal); REGISTER_LUA_CFUNC(SetGroundDecalTint); @@ -4600,6 +4601,29 @@ int LuaUnsyncedCtrl::SetGroundDecalTexture(lua_State* L) return 1; } +/*** + * + * @function Spring.SetGroundDecalTextureParams + * @number decalID + * @number texWrapDistance[opt=currTexWrapDistance] if non-zero sets the mode to repeat the texture along the left-right direction of the decal every texWrapFactor elmos + * @number texTraveledDistance[opt=currTexTraveledDistance] shifts the texture repetition defined by texWrapFactor so the texture of a next line in the continuous multiline can start where the previous finished. For that it should collect all elmo lengths of the previously set multiline segments. + * @treturn nil|bool decalSet + */ +int LuaUnsyncedCtrl::SetGroundDecalTextureParams(lua_State* L) +{ + auto* decal = groundDecals->GetDecalById(luaL_checkint(L, 1)); + if (!decal) { + lua_pushboolean(L, false); + return 1; + } + + decal->uvWrapDistance = luaL_optfloat(L, 2, decal->uvWrapDistance); + decal->uvTraveledDistance = luaL_optfloat(L, 3, decal->uvTraveledDistance); + + lua_pushboolean(L, true); + return 1; +} + /*** * diff --git a/rts/Lua/LuaUnsyncedCtrl.h b/rts/Lua/LuaUnsyncedCtrl.h index 0da3a2f6f1..ee79ee8071 100644 --- a/rts/Lua/LuaUnsyncedCtrl.h +++ b/rts/Lua/LuaUnsyncedCtrl.h @@ -193,6 +193,7 @@ class LuaUnsyncedCtrl { static int SetGroundDecalQuadPosAndHeight(lua_State* L); static int SetGroundDecalRotation(lua_State* L); static int SetGroundDecalTexture(lua_State* L); + static int SetGroundDecalTextureParams(lua_State* L); static int SetGroundDecalAlpha(lua_State* L); static int SetGroundDecalNormal(lua_State* L); static int SetGroundDecalTint(lua_State* L); diff --git a/rts/Lua/LuaUnsyncedRead.cpp b/rts/Lua/LuaUnsyncedRead.cpp index 2915d3954f..6e49e8de24 100644 --- a/rts/Lua/LuaUnsyncedRead.cpp +++ b/rts/Lua/LuaUnsyncedRead.cpp @@ -287,6 +287,7 @@ bool LuaUnsyncedRead::PushEntries(lua_State* L) REGISTER_LUA_CFUNC(GetGroundDecalRotation); REGISTER_LUA_CFUNC(GetGroundDecalTexture); REGISTER_LUA_CFUNC(GetGroundDecalTextures); + REGISTER_LUA_CFUNC(GetGroundDecalTextureParams); REGISTER_LUA_CFUNC(GetGroundDecalAlpha); REGISTER_LUA_CFUNC(GetGroundDecalNormal); REGISTER_LUA_CFUNC(GetGroundDecalTint); @@ -4621,6 +4622,27 @@ int LuaUnsyncedRead::GetGroundDecalTextures(lua_State* L) } +/*** + * + * @function Spring.SetGroundDecalTextureParams + * @number decalID + * @treturn nil|number texWrapDistance if non-zero sets the mode to repeat the texture along the left-right direction of the decal every texWrapFactor elmos + * @treturn number texTraveledDistance shifts the texture repetition defined by texWrapFactor so the texture of a next line in the continuous multiline can start where the previous finished. For that it should collect all elmo lengths of the previously set multiline segments. + */ +int LuaUnsyncedRead::GetGroundDecalTextureParams(lua_State* L) +{ + const auto* decal = groundDecals->GetDecalById(luaL_checkint(L, 1)); + if (!decal) { + return 0; + } + + lua_pushnumber(L, decal->uvWrapDistance); + lua_pushnumber(L, decal->uvTraveledDistance); + + return 2; +} + + /*** * * @function Spring.GetGroundDecalAlpha diff --git a/rts/Lua/LuaUnsyncedRead.h b/rts/Lua/LuaUnsyncedRead.h index 41c1dc3039..8426c9614f 100644 --- a/rts/Lua/LuaUnsyncedRead.h +++ b/rts/Lua/LuaUnsyncedRead.h @@ -208,6 +208,7 @@ class LuaUnsyncedRead { static int GetGroundDecalRotation(lua_State* L); static int GetGroundDecalTexture(lua_State* L); static int GetGroundDecalTextures(lua_State* L); + static int GetGroundDecalTextureParams(lua_State* L); static int GetGroundDecalAlpha(lua_State* L); static int GetGroundDecalNormal(lua_State* L); static int GetGroundDecalTint(lua_State* L);