forum code formatting: please use XCode

Discussion in 'Utilities and programming' started by tdev, Feb 5, 2015.

Thread Status:
Not open for further replies.
  1. tdev

    tdev
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 3, 2012
    Messages:
    3,031
    If you write this in a forum post:
    Code:
    [noparse][xcode=js]var x = 1;[/xcode][/noparse]
    it will produce this beautiful code:

    [xcode=js]var x = 1;[/xcode]


    and lua:
    Code:
    [noparse][xcode=lua] your code here [/xcode][/noparse]
    [xcode=lua]
    -- This Source Code Form is subject to the terms of the bCDDL, v. 1.1.
    -- If a copy of the bCDDL was not distributed with this
    -- file, You can obtain one at http://beamng.com/bCDDL-1.1.txt


    local M = {}


    M.values = {}
    local lastValues = {}
    local smoothValuesExp = {}
    M.disabledState = {}


    local lightsState = 0


    local wheelObj = -1
    local wheelRadius = 0


    local signalRightState = false
    local signalLeftState = false
    local signalWarnState = false


    local blinkPulse = false
    local blinkTimerThreshold = 0.4
    local blinkTimer = 0


    local function updateValue(func, smoothing)
    smoothing = smoothing or 0
    if M.disabledState[func] ~= nil then return nil end
    local val = nil


    if func == "steering" then
    local _, h
    for _, h in pairs (hydros.hydros) do
    if h.inputSource == "steering_input" then
    if h.steeringWheelLock and h.hydroDirState then
    val = -h.hydroDirState * h.steeringWheelLock
    break
    else
    val = -h.hydroDirState
    break
    end
    end
    end
    [/xcode]

    And JSON:

    Code:
    [noparse][xcode=json] your code here [/xcode][/noparse]
    [xcode=json]
    {
    "autohide": false,
    "title": ["UPDATES","STABLE BUILD"],
    "current" : "0.3.7.6",
    "content" : [
    {
    "title" : "0.3.7.6",
    "timestamp" : 1423124516,
    "type" : "stable",
    "content" : {
    "Bugfixes" : {"icon":"bug", "list":[
    "Many stability fixes in the physics core",
    "Fixed cache file loading: prefer non-cached version",
    "Fixed bug where vehicles could not be dragged around in the editor",
    "Pressure wheels support hubcaps again",
    "Disabled action menu for now until it is completely working"
    ]},
    "Vehicle Content" : {"icon":"car", "list":[
    "New cubemaps for car reflections",
    "Thumbnails for all vehicles",
    "Minor changes to sunburst body kit and rally lights mesh"
    ]},
    "Terrain Content" : {"icon":"world", "list":[
    "Overhauled skybox cubemaps for better reflections",
    "Minor improvements to ECA",
    "Updated palm trees and textures on DRI"
    ]}
    }
    },
    [/xcode]


    So if you use code, please use this :)
     
    #1 tdev, Feb 5, 2015
    Last edited: Feb 5, 2015
  2. Dummiesman

    Dummiesman
    Expand Collapse

    Joined:
    Sep 17, 2013
    Messages:
    4,684
    Thank you for adding in the Lua plugin :)
     
  3. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,960
    Which languages are supported?
     
  4. tdev

    tdev
    Expand Collapse
    Developer
    BeamNG Team

    Joined:
    Aug 3, 2012
    Messages:
    3,031
    i wonder :|

    UPDATE: i would have to look at the code. Just try some others.
     
    #4 tdev, Feb 9, 2015
    Last edited: Feb 9, 2015
  5. raiderfan

    raiderfan
    Expand Collapse

    Joined:
    Aug 5, 2012
    Messages:
    145
    Going out on a limb here but i'm going to guess js, lua, and json.
     
  6. SixSixSevenSeven

    SixSixSevenSeven
    Expand Collapse

    Joined:
    Sep 13, 2013
    Messages:
    6,960
    Python works, even if I am using .NET libraries in this snippet of code:
    [xcode=python]
    import clr #common language runtime, notably the actual .NET runtime is known as the CLR
    #clr.AddReference(System) #Commented out as System is referenced by default
    from System import Console
    Console.WriteLine("Hello, World!");
    Console.CursorLeft = Console.CursorLeft + 4
    from System import ConsoleColor
    Console.BackgroundColor = ConsoleColor.White
    Console.ForegroundColor = ConsoleColor.Red
    Console.WriteLine("From a .NET Console class")
    print "But good old python print statements still work"
    Console.ReadKey()
    Console.ResetColor()
    Console.Clear()
    Console.WriteLine("Oh, its not pwettyfull anymore")
    Console.ReadLine()[/xcode]
     
Thread Status:
Not open for further replies.
  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