Solved .json help for scenario

Discussion in 'Mod Support' started by Swordfish, Aug 14, 2016.

  1. Swordfish

    Swordfish
    Expand Collapse

    Joined:
    Aug 4, 2016
    Messages:
    10
    Hey, I'm trying to get some waypoints in my scenario to pass messages when they are taken, but when I add the following bit of code to my .json file, every scenario disappears from the menu, and when I delete it, they all reappear. Some help please? Thanks!!

    "goal":
    "wayPointAction":
    { "wayPointNum":[6],
    "wayPointMsg":["Park your trailer at the next waypoint, backing it into the alley. Your next trailer is in the warehouse, you must find a way to get back to this parking lot for the next waypoint."],
    "wayPointNum":[17],
    "wayPointMsg":["Park your trailer at the next waypoint, backing in between buildings, then pick up the next trailer."] }

    And here is the rest of my file:

    [
    {
    "name": "Truck route",
    "description": "This truck route will take you to different areas, where every time, you must pick up a trailer. At the next area, you must deliver it, and pick up the next one. Key waypoints will give you instructions, so pay attention.",
    "previews": ["my_first_scenario.jpg"],
    "type": "race",
    "authors": "Swordfish",


    "difficulty": "10",

    "vehicles":
    {
    "scenario_player0":
    {
    "driver":
    { "player": true,
    "startFocus": true,
    "required": true
    },
    },

    "*": {"playerUsable": false},

    }

    "whiteListActions": ["default_whitelist_scenario" ],
    "blackListActions": ["default_blacklist_scenario" ],

    "lapConfig": ["W1", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w9", "w10", "w11", "w12", "w13", "w14", "w15", "w16", "w17", "w18", "w19", "w20", "w21", "w22", "w23", "w24", "w25", "w26", "w27", "w28", "w29", "w30"],
    "prefabs": ["my_first_scenario"],
    "radiusMultiplierAI": 2
    },
    ]

    My bit of code was inserted right after the "driver" subsection, and I'm pretty sure after checking five times that I respected the { } placements.

     
  2. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    Please attach the actual file so that we can easily open it in a syntax-highlighting text editor like Notepad++.
     
  3. Funky7Monkey

    Funky7Monkey
    Expand Collapse

    Joined:
    Oct 12, 2014
    Messages:
    977
    I am not positive, as I haven't tested this, but I think you need to have separate wayPointAction goals (within goal) for each action.
     
  4. Swordfish

    Swordfish
    Expand Collapse

    Joined:
    Aug 4, 2016
    Messages:
    10
    Here is my file, as it stands, it prevents every scenario from appearing in the game. I tried to make it as neat as possible, and I can't see where it doesn't work. I based myself on the Wiki page for creating scenarios, but the structure was not the same -- the wiki says there is a driver and a goal section for each vehicle, whereas the original scenario file (from the kit downloaded here) didn't have those subsections.


    I also added some commands I wanted for the entity "brokendown" ... I basically want the truck to have hazard lights blinking, engine not running and in park... all three of my commands don't work either. I tried rummaging through everything I could find here, but I can't understand where I'm going wrong.
     

    Attached Files:

    #4 Swordfish, Aug 15, 2016
    Last edited: Aug 15, 2016
  5. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    Thanks for posting the file, that makes it much easier to help! Unfortunately you did become confused about where the brackets needed to be. There were many errors, so I'm attaching a screenshot of a diff (to show the changes made) as well as a replacement file that functions.
     

    Attached Files:

    • Like Like x 1
  6. Swordfish

    Swordfish
    Expand Collapse

    Joined:
    Aug 4, 2016
    Messages:
    10
    Ok, so I worked on my file for some time, and I believe I have corrected the syntax. I have two versions of the file uploaded now. One, without the wayPointAction subsections, and one with. the one without works perfectly, and yet the one with them continues to make the scenario menu blank. I'm at a loss right now.

    btw... if you can look at the "brokendown" section and tell me why none of the three commands are working. I want the truck with hazard lights, engine not running and vehicle in park.
    Thanks for helping me out. I will make this mod public once it works, and credit will be given to those who helped!
     

    Attached Files:

    #6 Swordfish, Aug 15, 2016
    Last edited: Aug 15, 2016
  7. Swordfish

    Swordfish
    Expand Collapse

    Joined:
    Aug 4, 2016
    Messages:
    10
    Ugh. Just saw I missed a semicolon in one of the sections. I will correct it when I get home from work... going that's the only mistake I made write regards fire that section.
     
  8. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    Yes, missing a colon not a semicolon though. :) I'm not sure how important the commas are to the syntax, but you might want to emulate the comma usage from the stock scenarios as well. EDIT: To be clear, I know that your scenario loads without commas between the waypointAction sections, I just don't know whether this will cause any problems in the future.
     
  9. Swordfish

    Swordfish
    Expand Collapse

    Joined:
    Aug 4, 2016
    Messages:
    10
    Alright. So the colon was the big missing piece so as to not cause the game indigestion. However, as with my commands for the "brokendown" vehicle not working, when I reach the checkpoints, the messages do not show up. The only parts of my .JSON file that work and respond correctly are the time of day parameters. I'll be pouring over this for a while I think... thanks for your help.
     
  10. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    I haven't looked any more but I recommend addressing any missing commas before anything else.

    I can't do much for you without the other files (prefab etc). Send me a PM if you want.
     
  11. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    Here's an updated JSON. For the sake of troubleshooting I've made some temporary changes:
    • The messages are on waypoint 1 / 2 / 3

    In terms of fixing things up:
    1. I've added a few commas.
    2. drivetrain.disableEngine() is not a real command which you can use. Clearly you grabbed this function name from drivetrain.lua, but you should take a look at the public interface section at the bottom - this function is not exported and is therefore only available inside drivetrain.lua (eg only other functions inside drivetrain.lua can use that function).
    3. wayPointAction and wayPointMsg are actually arrays. Note that I've serialized the numbers and messages using commas. This functions correctly.
    4. I added a "driver" section to "brokentruck" and put the other stuff inside it.
    5. The commands in "command" must be one line of valid Lua. While I've used the semicolon for clarity, that probably isn't actually necessary for valid lua - spaces would probably work.In any case, take note of what I've done to get those commands together.
    I'd say that what you were trying to do with brokentruck was based on your knowledge of real life: you want the truck immobile so you put it in gear and disabled the engine. This won't work in the game. (a) you can't disable the engine like that (b) the game will automatically use the clutch! Instead I recommend that you make a custom .pc file and remove the engine, then toggle the parking brake (if possible?) in the Lua commands to immobilize the truck. Maybe you could use input.toggleEvent('parkingbrake')?

    I'll explain what was happening with the existing JSON file both in the case of the wayPointAction and in the case of the command. Each successive one was simply overwriting the previous one (since they referred to the same thing!). Therefore the final command was being executed (it was an invalid command anyway) and the final wayPointAction was also being executed (it was working fine!).

    Code:
    [
    {
        "name": "Truck route",
        "description": "This truck route will take you to different areas, where every time, you must pick up a trailer. At the next area, you must deliver it, and pick up the next one. Key waypoints will give you instructions, so pay attention.",
        "previews": ["truck_route.jpg"],
        "type": "race",
        "authors": "Swordfish",
        "difficulty": "10",
        "levelObjects":
            {
            "tod":  
                {
                "play": true
                "dayLength": 600000
                "time": 1
                }
            }
    
        "vehicles":
        {
            "scenario_player0":
            {
                "driver":
                {    "player": true,
                    "startFocus": true,
                    "required": true
                },
                "goal":
                {
                "wayPointAction":
                    {
                    "wayPointNum":[1,2,3]
                    "wayPointMsg":["Park your trailer at the next waypoint, backing it into the alley. Your next trailer is in the warehouse, you must find a way to get back to this parking lot for the next waypoint.","Park your trailer at the next waypoint, backing in between buildings, then pick up the next trailer.","At the next check point, park the trailer in the pull-out. A fellow trucker has broken down and your boss needs you to take his load in priority."]
                    }
                }
            },
            "brokendown":
            {
                "driver":
                {
                    "player": false
                    "playerUsable": false,
                    "command":"electrics.toggle_warn_signal(); drivetrain.shiftToGear(1); electrics.toggle_lights();",
                }
            },
            "*":
            {
                "playerUsable": false
            }
        }
        "whiteListActions": ["default_whitelist_scenario" ],
        "blackListActions": ["default_blacklist_scenario" ],
     
        "lapConfig": ["W1", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w9", "w10", "w11", "w12", "w13", "w14", "w15", "w16", "w17", "w18", "w19", "w20", "w21", "w22", "w23", "w24", "w25", "w26", "w27", "w28", "w29", "w30"],
        "prefabs": ["truck_route"],
        "radiusMultiplierAI": 2
    },
    ]
    
     

    Attached Files:

  12. bobby_boulgat

    bobby_boulgat
    Expand Collapse

    Joined:
    Aug 23, 2013
    Messages:
    481
    may be replace "truck route" by "truck_route", in more your jpg have already this name. the spaces make the shit, i have had the case with my pépé René's truck missions
    here you have: name "truck route" <= replace " " by "_"
    prefab "truck_route"
    preview "truck_route"
     
  13. torsion

    torsion
    Expand Collapse

    Joined:
    May 31, 2015
    Messages:
    1,600
    Spaces in the doublequote encased name field are fine! Take a look at the stock scenarios and all over the place - spaces are fine in that field just like in description. If you take a look at my posts in this thread (especially #11) I've explained all the problems. (If I missed one please point it out!)
     
  14. bobby_boulgat

    bobby_boulgat
    Expand Collapse

    Joined:
    Aug 23, 2013
    Messages:
    481
    excuse me, i had "read" very very quickly ...
    i don't have the solution but maybe these waypoints have the same names than in an other scenarios. i believe it's problematic, also, when you play several scenar consecutively... after, i'm not a specialist. it's just a suggestion. just want to help if i can
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice