Using Bing Chat to write Lua code for Controls Container
  • timbrass
    activ8 member
    Posts: 57
    Joined: Mon Mar 01, 2021 9:01 pm
    Contact:

    Using Bing Chat to write Lua code for Controls Container

    by timbrass » Sat Aug 05, 2023 9:30 pm

    I was experimenting with writing Lua code in the Controls Container module (where you take up to 3 inputs and perform maths on them and create a new output variable. I am not a programmer, so I tried using Bing Chat to write the code for me. It worked well!

    I typed the following into Bing Chat "write lua code that takes 3 variables input1, input2 and input3 and returns a variable called output. The code should return the highest value of the three variables"

    It produced...
    ===========================
    function max(a,b,c)
    return math.max(a,b,c)
    end

    output = max(input1,input2,input3)
    ===========================
    This successfully ran unmodifed when cut and pasted into Lua window in Controls Combiner module.

    I then typed into Bing Chat "Rather than return the highest value, return the average value"

    This produced the following which ran successfully unmodified
    ============================================
    function average(a,b,c)
    return (a+b+c)/3
    end

    output = average(input1,input2,input3)
    ============================================

    I then typed into Bing Chat "write lua code that takes 2 variables input1 and input2 and returns a variable called output. The code should return the sum of the squares of the 2 input variables"

    ============================================
    function sum_of_squares(a,b)
    return a^2 + b^2
    end

    output = sum_of_squares(input1,input2)
    ============================================

    So if you are useless at writing code then use Bing Chat (free implementation of ChatGPT) to do it for you.

Who is online

Users browsing this forum: No registered users and 5 guests