Tech Methods
Complete reference of all methods available on TechManager and TechHandle.
TechManager Methods
Access via workspace.tech_manager
# First, define the manager
tech_manager = workspace.tech_managerget(tech_id)
Get a tech by ID.
def get(tech_id: int) -> TechHandle| Parameter | Type | Description |
|---|---|---|
tech_id | int | The tech ID |
Returns: TechHandle
Raises: InvalidIdError if tech doesn't exist
loom = tech_manager.get(22)
print(f"Research time: {loom.research_time}")add_new(name="", effect_id=-1, tech_id=None) / create(...)
Create a new technology.
def add_new(
name: str = "",
effect_id: int = -1,
tech_id: Optional[int] = None,
) -> TechHandle| Parameter | Type | Default | Description |
|---|---|---|---|
name | str | "" | Tech name |
effect_id | int | -1 | Linked effect ID (-1 = none) |
tech_id | int | None | Target ID. None = append |
Returns: TechHandle
# Create with linked effect
tech = tech_manager.create("My Tech", effect_id=500)
# Create at specific ID
tech = tech_manager.create("My Tech", tech_id=800)copy(source_id, target_id=None)
Copy a tech to a new ID.
def copy(source_id: int, target_id: Optional[int] = None) -> TechHandleReturns: TechHandle
copied = tech_manager.copy(22) # Copy Loomdelete(tech_id)
Reset a tech to blank values.
def delete(tech_id: int) -> boolReturns: True if deleted
exists(tech_id)
Check if a tech exists.
def exists(tech_id: int) -> boolcount() / count_active()
Get total tech slots or non-None count.
print(f"Total: {tech_manager.count()}")find_by_name(name)
Find first tech matching name.
def find_by_name(name: str) -> Optional[TechHandle]Clipboard Operations
tech_manager.copy_to_clipboard(22)
pasted = tech_manager.paste()
tech_manager.clear_clipboard()TechHandle Methods
Cost Management
set_cost.cost_1(resource_type, amount, deduct=True)
Set cost slot 1 using the CostBuilder pattern.
| Parameter | Type | Default | Description |
|---|---|---|---|
resource_type | int | Required | 0=Food, 1=Wood, 2=Stone, 3=Gold |
amount | int | Required | Amount required |
deduct | bool | True | Whether to deduct resource |
# Set costs using builder pattern
tech.set_cost.cost_1(3, 100) # 100 Gold
tech.set_cost.cost_2(0, 50) # 50 Food
tech.set_cost.cost_3(1, 75, False) # 75 Wood, don't deductclear_cost(slot)
Clear a specific cost slot.
tech.clear_cost(0) # Clear slot 1clear_all_costs()
Clear all cost slots.
tech.clear_all_costs()get_cost(slot)
Get cost at slot as tuple.
Returns: Tuple[int, int, int] - (resource_id, quantity, deduct_flag)
resource, amount, deduct = tech.get_cost(0)
print(f"Cost 1: {amount} of resource {resource}")Required Techs
set_required_tech(slot, tech_id)
Set a required tech at a slot.
| Parameter | Type | Description |
|---|---|---|
slot | int | Slot (0-5) |
tech_id | int | Required tech ID (-1 to clear) |
tech.set_required_tech(0, tech_id=101) # Require Castle Age
tech.set_required_tech(1, tech_id=22) # Require Loomclear_required_techs()
Clear all required tech slots.
tech.clear_required_techs()Research Locations
add_research_location(unit_id, button_id=0, ...)
Add a location where this tech can be researched.
| Parameter | Type | Default | Description |
|---|---|---|---|
unit_id | int | Required | Building unit ID |
button_id | int | 0 | UI button position |
# Research at Blacksmith
tech.add_research_location(unit_id=103, button_id=5)See Research Locations for details.
get_research_location(index)
Get a research location by index.
loc = tech.get_research_location(0)
print(f"Research at: {loc.unit_id}")remove_research_location(index)
Remove a research location.
tech.remove_research_location(0)clear_research_locations()
Remove all research locations.
tech.clear_research_locations()exists()
Check if this tech entry exists.
if tech.exists():
print(f"Tech: {tech.name}")