Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
A clua interface for scrolls of acquirement
With the despoilering of acquirement in 0.25, a lua interface to the acquirement menu is necessary so that clua users can inspect the results and determine which item to choose. This commit adds a hook c_choose_acquirement() that is called if it's defined in clua. It's expected to return a valid index from the set of choices, using 1 for the first item as is customary for lua. If no c_choose_acquirement function is found, or if the call generates an error, or if the returned index is invalid, the acquirement proceeds normally to the acquirement menu. A valid call and return index will cause the indicated item to be acquired, bypassing the menu. This commit also adds items.acquirement_items() to the items library, which returns a lua array of items.Item representations of the generated items. All item details are provided, since acquirement gives fully identified items. If acquirement is not in progress, this function returns nil. Any c_choose_acquirement() function should call items.acquirement_items() and inspect the results to make a determination. I'll later add a commit to elliptic/qw#30 to add support for 0.25 acquirement to qw using this interface. Ideally we'd not have to have items.acquirement_items as its own function and could just pass the item table as an argument to c_choose_acquirement. I'm not sure if lua's "light userdata" facility can accommodate this, and we have limited support passing arguments from C++ to lua. If it turns out to be possible, we can refactor the interface in a later commit.
- Loading branch information