So I've got a pretty complex scenario, I got almost everything working, except from the "win" condition. What I need is a .lua file that will "count" whenever you've passed through specific checkpoints (not every checkpoint- only specific ones), and after you passed through a defined number of them, it will send a "success" to the game (you win). Problem is, I don't know .lua at all. If you know a bit of .lua, and can help by explaining what functions I need to use, or by sending a link that will help me learn Beamng lua basics, or even better- if you could build a template file, I'd really appreciate that.
Check out the Tanker Delivery LUA script for reference, but I think you could do (this is abbreviated): local count = 0 Onplayerentercheckpoint { count++; if(count == somenumber) { win } }
Here's my non-abbreviated version. It works!!! I'm happy now. Good night. HTML: local M = {} local helper = require('scenario/scenariohelper') local running = false local scenario = nil local count = 0 local function success(reason) scenario_scenarios.finish({msg = reason}) end local function onRaceWaypointReached(data) local playerVehicleId = be:getPlayerVehicleID(0) if data.vehicleId == playerVehicleId then if data.waypointName == 'waypoint_15' then count = count + 1 ---- got to admit- I'm surprised it worked. This is Basic's syntax (The only language I ever learned was Basic), but apparently it's fine by Lua. So... Yay! end if data.waypointName == 'waypoint_29' then count = count + 1 end if(count == 2) then success('You made it!') end end end M.onRaceWaypointReached = onRaceWaypointReached return M