Dwelling Wood Cost
Addon module for Dwellings and Lumberyard systems. Makes purchasing dwellings require wood as a building material (in addition to gold and gems). Configurable wood cost per dwelling type. Track wood spent incrementally. Pay for dwelling in installments (wood, gold, gems separately). Requires Lumberyard module for wood supply.
Requirements
- Dwellings module: Core housing system
- Lumberyard module: Wood production system
- This module: Bridges the two systems
Without Dwellings and Lumberyard installed, this module does nothing.
How It Works
Purchasing a Dwelling:
- Browse available dwelling types
- Each type has THREE costs: gold, gems, and wood
- Example: Cottage = 5000 gold + 2 gems + 5 wood (default woodcost)
- Pay costs incrementally (like normal Dwellings module)
Paying Wood Cost:
- Visit dwelling purchase page
- Input field: "Wood: [___]"
- Enter amount of wood to spend (from your Lumberyard squares)
- Submit → Wood deducted from lumberyard, added to dwelling progress
- Repeat until full wood cost paid
Wood Tracking:
- Each dwelling tracks "woodspent" pref
- Remaining wood cost = dwelling type woodcost - woodspent
- Dwelling incomplete until ALL costs paid (gold, gems, wood)
Wood Source (Lumberyard)
Lumberyard Module:
- Produces wood via "squares" (lumber production units)
- Wood stored in lumberyard allprefs['squares']
- Spending wood on dwelling reduces your lumberyard squares
Example Workflow:
- Earn 10 wood squares from Lumberyard activities
- Start building dwelling that costs 5 wood
- Pay 3 wood → woodspent = 3, lumberyard = 7 squares
- Pay 2 wood → woodspent = 5, lumberyard = 5 squares
- Wood cost complete! (Still need to pay gold/gems)
Validation
Prevents Overspending:
- Can't spend more wood than you have in lumberyard
- Can't spend more wood than dwelling requires
- Error messages: "You do not have that much wood" or "You have tried to spend more wood than you need to."
- Blocks navigation to build page if validation fails
Input Sanitization:
- Wood input converted to absolute integer (abs((int)httppost('paidwood')))
- Negative values converted to 0
- Prevents exploits via negative wood inputs
Admin Configuration
Per Dwelling Type:
- Setting: "woodcost" (default: 5 wood per dwelling)
- Configurable per dwelling type (cottage, mansion, castle, etc.)
- Can set different wood costs for different dwelling tiers
Example Settings:
- Tent: 1 wood (cheap starter dwelling)
- Cottage: 5 wood (moderate dwelling)
- Mansion: 20 wood (expensive dwelling)
- Castle: 50 wood (elite dwelling)
Adjust woodcost to balance economy with Lumberyard wood production rate.
Hooks Used
- dwellings-pay-costs: Display remaining wood cost on dwelling page
- dwellings-pay-input: Add wood input field to payment form
- dwellings-buy-setup: Process wood payment, update woodspent, deduct from lumberyard
- dwellings-buy-valuecheck: Validate wood payment amount before processing
Impact on Gameplay
Before This Module:
- Dwellings cost only gold and gems
- Lumberyard wood used for other purposes (or unused)
- No connection between housing and resource gathering
After This Module:
- Dwellings require THREE resources: gold, gems, wood
- Lumberyard becomes essential for housing
- More complex economy with interdependent systems
- Players must balance wood for dwellings vs wood for other uses
Strategy
For Players:
- Check dwelling wood cost before starting purchase
- Ensure you have enough lumberyard wood stockpiled
- Pay wood cost incrementally (don't dump all wood at once)
- Balance wood spending: dwellings vs other wood-consuming modules
For Admins:
- Set woodcost proportional to Lumberyard wood production rate
- If wood is easy to get: High woodcost (20-50 per dwelling)
- If wood is scarce: Low woodcost (1-5 per dwelling)
- Test economy balance before setting high woodcosts
Compatibility
- Requires Dwellings module 20051118 or later
- Requires Lumberyard module 5.0 or later
- Compatible with other dwelling addons (Dwelling Upgrades, etc.)
- Compatible with other wood-consuming modules
Multiple modules can consume wood from the same lumberyard pool.
Dwelling Wood Cost: where your dream home now requires not just gold and gems, but also a lumberyard full of wood, because apparently magical wizards still need mundane construction materials. At least you can pay in installments, so you can slowly watch your lumber stockpile disappear one plank at a time.