Skip to content

Fix set lua textures with numbers#4867

Merged
Loobinex merged 4 commits into
dkfans:masterfrom
Shinthoras0815:fix-set-lua-textures-with-numbers
Jun 3, 2026
Merged

Fix set lua textures with numbers#4867
Loobinex merged 4 commits into
dkfans:masterfrom
Shinthoras0815:fix-set-lua-textures-with-numbers

Conversation

@Shinthoras0815
Copy link
Copy Markdown
Contributor

Fixes #4813.

This change introduces a consistent texture ID scheme for both PLAYER:set_texture() and Map.default_texture:

Integer IDs are now 0-based (0 = tmapa000.dat).
-1 is used as the reset value for set_texture.
Named texture strings continue to work as before.
Integer and string inputs are handled separately to avoid ID translation issues.

Copilot AI review requested due to automatic review settings June 2, 2026 06:10
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Updates Lua-facing texture selection to support numeric IDs (0-based) alongside named texture packs, and aligns internal storage/index conversions for player textures and map default textures.

Changes:

  • Add numeric/negative handling in Lua Set_texture and MAP.default_texture setter.
  • Convert between 0-based (Lua numeric) and 1-based (internal/enum) texture IDs.
  • Adjust slab texture reset behavior to use negative IDs as “reset”.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

File Description
src/slab_data.c Changes reset conditions and normalization for player texture selection.
src/lua_api_player.c Allows numeric texture IDs in Lua player texture API; maps indices/reset values.
src/lua_api_map.c Adjusts MAP.default_texture get/set to support 0-based numeric IDs and internal 1-based storage.
Comments suppressed due to low confidence (1)

src/lua_api_map.c:1

  • If get_conf_parameter_text() returns an empty string and game.texture_id is 0, this will push -1 to Lua. That’s likely unintended for a getter. Consider guarding the subtraction (eg. only subtract when game.texture_id > 0, otherwise return 0 or a sentinel like nil), or ensure game.texture_id cannot be 0 in the “custom/empty name” case.
#include "pre_inc.h"

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/slab_data.c
Comment thread src/slab_data.c Outdated
Comment thread src/slab_data.c Outdated
Comment thread src/slab_data.c Outdated
Comment thread src/lua_api_player.c
Comment thread src/lua_api_map.c
Comment thread src/slab_data.c
@Loobinex Loobinex merged commit 30d8c59 into dkfans:master Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Lua: SetTexture shows wrong texture when using number

4 participants