Skip to content

fix(loot): preserve text on monster loot items - #449

Open
hexbranch wants to merge 1 commit into
atlas-kit:devfrom
hexbranch:fix/monster-loot-text
Open

hexbranch wants to merge 1 commit into
atlas-kit:devfrom
hexbranch:fix/monster-loot-text

Conversation

@hexbranch

@hexbranch hexbranch commented Oct 4, 2026 •

Copy link
Copy Markdown

Problem

In data/lib/core/container.lua, Container.createLootItem calls tmpItem:setText(item.text) when an item dropped as monster loot has configured text:

if item.text and item.text ~= "" then
	tmpItem:setText(item.text)
end

However, Item:setText() is not registered in the Atlas Lua API (src/lua/modules/item.cpp). When a monster drop contains an item with text (such as readable notes or quest/lore documents), createLootItem fails with a runtime error attempting to call method setText (a nil value).

Fix

Replace the invalid tmpItem:setText(item.text) call with the supported Atlas Lua attribute method:

tmpItem:setAttribute(ITEM_ATTRIBUTE_TEXT, item.text)

No new C++ bindings are introduced, and all existing loot logic (actionId, chance, subtype, and child loot behavior) is preserved.

Validation

  • Verified syntax of data/lib/core/container.lua using AST parser.
  • Executed unit tests suite (ctest).
  • Verified zero formatting or whitespace issues with git diff --check.
  • Diff is strictly minimal: 1 line changed in data/lib/core/container.lua.

Closes #448

Summary by CodeRabbit

  • Bug Fixes
    • Nonempty text on generated loot items is now stored as an item attribute, preserving the expected item text behavior.

Container.createLootItem called tmpItem:setText(item.text) when generating monster loot items with configured text. However, Item:setText is not registered in the Atlas Lua API (src/lua/modules/item.cpp), causing a runtime error when dropping written documents or notes.

Use the supported Atlas Lua attribute API: tmpItem:setAttribute(ITEM_ATTRIBUTE_TEXT, item.text).

Closes atlas-kit#448
@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 944b0862-ca59-49fc-9d44-b268ae668a5a
📥 Commits

Reviewing files that changed from the base of the PR and between 09fe456 and db22b03.

📒 Files selected for processing (1)
  • data/lib/core/container.lua

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

Container.createLootItem now assigns nonempty loot text with setAttribute(ITEM_ATTRIBUTE_TEXT, item.text).

Changes

Loot item text

Layer / File(s) Summary
Assign loot item text
data/lib/core/container.lua
For items with nonempty text, Container.createLootItem uses setAttribute with ITEM_ATTRIBUTE_TEXT instead of setText.

Priority: ➖ Normal

Estimated code review effort: 2 (Simple) | ~5 minutes

Change: Bug fix · Severity of issue fixed: Medium

Merge Risk: ⚪ Minimal · up to db22b

The loot text change preserves the existing text-reading and serialization behavior, with no identified merge-blocking risk.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: preserving text on monster loot items.
Linked Issues check ✅ Passed Issue #448 requires assigning configured monster-loot text through setAttribute(ITEM_ATTRIBUTE_TEXT, item.text). The PR replaces the unsupported tmpItem:setText(item.text) call in `Container.creat…
Out of Scope Changes check ✅ Passed The reported one-line change only updates monster-loot text assignment, which directly addresses issue #448. No unrelated changes are reported.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

This branch has not been deployed

No deployments
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.

Monster loot creation fails on items with text due to missing Item:setText

1 participant