68 lines
2.2 KiB
Markdown
68 lines
2.2 KiB
Markdown
# NuCon (Nucleares Controller)
|
|
|
|
NuCon is a Python library designed to interface with and control parameters in the game Nucleares, a nuclear reactor simulation game. This library provides a robust and type-safe way to interact with various reactor components and systems.
|
|
|
|
## Features
|
|
|
|
- Enum-based parameter system for type safety and code clarity
|
|
- Support for various parameter types including floats, integers, booleans, strings, and custom enums
|
|
- Read and write capabilities for game parameters
|
|
- Custom truthy values for status enums to simplify conditional logic
|
|
- Dummy mode for testing without connecting to the game
|
|
- Batch operations for getting multiple parameters at once
|
|
|
|
## Installation
|
|
|
|
To install NuCon, clone this repository and install via pip:
|
|
```bash
|
|
pip install -e .
|
|
```
|
|
|
|
## Usage
|
|
|
|
Here's a basic example of how to use NuCon:
|
|
|
|
```python
|
|
from nucon import Nucon, BreakerStatus
|
|
|
|
# Set the base URL for the game's API (if different from default)
|
|
Nucon.set_base_url("http://localhost:8080/")
|
|
|
|
# Enable dummy mode for testing (optional)
|
|
Nucon.set_dummy_mode(True)
|
|
|
|
# Read a parameter
|
|
core_temp = Nucon.CORE_TEMP.value
|
|
print(f"Core Temperature: {core_temp}")
|
|
|
|
# Read a parameter with an enum type
|
|
pump_status = Nucon.COOLANT_CORE_CIRCULATION_PUMP_0_STATUS.value
|
|
print(f"Pump 0 Status: {pump_status}")
|
|
|
|
# Write to a parameter
|
|
Nucon.GENERATOR_0_BREAKER.value = BreakerStatus.OPEN # or True
|
|
print(f"Generator 0 Breaker Status: {Nucon.GENERATOR_0_BREAKER.value}")
|
|
|
|
# Use custom truthy values
|
|
if Nucon.COOLANT_CORE_CIRCULATION_PUMP_0_STATUS.value:
|
|
print("Pump 0 is active")
|
|
```
|
|
|
|
## API Reference
|
|
|
|
The `Nucon` enum contains all available parameters. Each parameter is defined with:
|
|
- An ID (string)
|
|
- A type (float, int, bool, str, or a custom Enum)
|
|
- A boolean indicating whether it's writable
|
|
|
|
Key methods:
|
|
- `Nucon.set_base_url(url)`: Set the base URL for the game's API
|
|
- `Nucon.set_dummy_mode(bool)`: Enable or disable dummy mode for testing
|
|
- `Nucon.get_all()`: Get all parameter values
|
|
- `Nucon.get_multiple(params)`: Get values for multiple specified parameters
|
|
|
|
For a full list of parameters and their details, refer to the `Nucon` enum in the source code.
|
|
|
|
## Disclaimer
|
|
|
|
NuCon is an unofficial tool and is not affiliated with or endorsed by the creators of Nucleares. |