/**
 * @author: Reconx86
 * @version: N/A
 * @created: 2016.03.22
 * @date: 2016.03.22
 *
 * RCX Local Configuration Script
 *
 * This script is meant to provide configuration settings for the main and engine script.
 * P = Placeholder are settings that may not work yet, but will be made functional in the future
 */

string localConf;
string engConf;

postLocalConf()
{
    llOwnerSay("Loading Local Configuration");
    llMessageLinked(LINK_SET, 0, localConf, "");
}

postEngConf() {
    llOwnerSay("Loading Engine Configuration");
    llMessageLinked(LINK_SET, 0, engConf, "");
}

// PH: Placeholder are settings that do not work yet, but will be implemented in the future
default
{
    state_entry()
    {
        // Data is send to MAIN and Engine Sound script
        localConf = llList2Json(JSON_OBJECT,
            [
                "msg", "conf.main",
                
                // Model Specifications
                "brand", "RCX",
                "model", "Eagle Mk2",
                "propulsion", "turboprop",
                
                // Main Settings
                "narrate", JSON_TRUE,// Enables thrust narration by default
                "gpws", JSON_FALSE,
                "taxi_angle", 12,
                
                // Door Settings
                "stair.enabled", JSON_FALSE,
                "stair.pos", <0.0, 0.0, 0.0>, // Enter position for stairs
                "stair.rot", <0, 0, 0>, //Enter rotation for stairs
                "door.open", JSON_TRUE, // Door status when plane rezzes
                
                // Seat Settings
                "seat.message", "Join secondlife:///app/group/428038ab-a600-6a27-dc70-6f5165c39fcb/about for group flights and to share your own mods withs us (group posts allowed)"
            ]);
        postLocalConf();
        
        // Data is send to Engine script
        engConf = llList2Json(JSON_OBJECT,
            [
                "msg", "conf.engine",
                
                // Float Settings
                "float.height", 0.25,
                
                // Thrust settings:
                "thrust.increments", 5,// Thrust percentage (%) per increment
                "thrust.min", -20,// Maximum number of increments to reach reverse-threshold
                "thrust.max", 100,// Minimum number of increments to reach forward-threshold
                
                // Speed settings
                "speed.full", 20.0,// Approximate speed at 100% thrust (in m/s)
                "speed.landing", 8.0,// Landing speed in m/s
                "speed.cruise", 10.0,// Speed at which you achieve full lift (VS1G)
                
                //Fuel settings
                "fuel.unit", "%",// Fuel unit 
                "fuel.total", 100,// Total fuel units
                "fuel.time", 600,// Fuel duration in seconds
                "fuel.flow", 1,//P: Consumption rate in fuel units per second
                "refuel.flow", 3//P: Rate of refueling
                
            ]);
        postEngConf();
        
    }
    
    link_message(integer sender_num, integer num, string msg, key id)
    {
        if (msg == "#main.state_entry") {
            postLocalConf();
            
        } else if (msg == "#engine.state_entry") {
            postEngConf();
        }
    }
}