Custom data sources
You can influence stock prices from your own scripts by returning a numeric factor from a function per stock id:config.lua
Database table structure
The stock market system uses a database table calledstocks to store all stock configurations. Each stock is defined by a single row in this table with the following fields:
Stock table fields
Basic information
Basic information
- id (string): Unique stock identifier (e.g., “VCC”, “AMCO”)
- label (string): Display name shown to players (e.g., “Valentine Coal Co.”)
- description (string): Detailed description of the company/stock
- base_price (integer): Initial stock price when first created
- volatility (float): Price volatility multiplier (1.0 = normal, 2.0 = double volatility)
- enabled (boolean): Whether the stock is active and tradeable
Stock type configuration
Stock type configuration
- type (string): Stock calculation method - “realtime”, “random”, “custom”, or “mixed”
- realtime_source (string): API provider name for real-time data (e.g., “api_provider”)
- realtime_symbol (string): Stock symbol for real-time data (e.g., “AAPL”, “TSLA”)
- realtime_weight (float): Influence of real-time data on price (0.0 to 1.0)
- random_enabled (boolean): Enable random price fluctuations
- random_weight (float): Influence of random fluctuations on price (0.0 to 1.0)
- random_max_change (float): Maximum percentage change per update cycle
- custom_weight (float): Influence of custom data sources on price (0.0 to 1.0)
Item integration
Item integration
- Currently disabled
Dividend settings
Dividend settings
- dividends_enabled (boolean): Enable dividend payouts for this stock
- dividends_mode (string): “fixed” for set amount or “percent” for percentage
- dividends_amount (float): Fixed dividend amount (used when mode is “fixed”)
- dividends_percent (float): Dividend percentage (used when mode is “percent”)
RP events
RP events
- rp_events_enabled (boolean): Enable RP events to affect this stock’s price
Stock type examples
Real-time stock
Real-time stock
Random stock
Random stock
Mixed stock
Mixed stock
Custom stock
Custom stock