Spends a cost from an inventory node found in the scene tree. Set costs and a locator that finds the inventory under the player that owns the placement. To pass the inventory in from code instead, use SpendByIdRule. The same ids are used for refunds (see BuildCost).
The inventory node needs these methods:
• get_count_by_id(id: StringName) -> int
• try_remove_by_id(id: StringName, amount: int) -> int
• try_add_by_id(id: StringName, amount: int) -> int (used to give items back)
Source: addons/grid_placement/placement/placement_rules/template_rules/spend_materials_rule_by_id.gd
Syntax
class SpendMaterialsRuleById extends SpendCostRuleBaseMembers
| Name | Kind | Summary |
|---|---|---|
locator | Property | Finds the inventory node to spend from, under the player that owns the placement. |
get_setup_issues | Method | |
requires_placer | Method | |
setup | Method | |
tear_down | Method |
Guides that use this class
Tutorials built on Grid Placement
- Godot multiplayer grid placement: one host, four sessions
- Godot 2D grid building system: paint, place, save
- Godot 3D grid building system: the runtime loop
- Godot 4 grid-building plugins: build mode vs editor tools
- 3D room placement in Godot: build rooms and stack storeys
- 3D grid placement in Godot 4: full setup tutorial
- Snap to a TileMap in Godot: 2D grid placement
- How to make a farming system in Godot
- How to snap objects to a 3D grid in Godot