Checkbox is a nil value

  • derpyt
    18th Feb 2015 Member 0 Permalink

    Im making a script manager for myself (i know that there already exists one).

    I keep getting the error "autorun.lua:68: attempt to index global 'cb1' (a nil value)" even though ive already defined it.

    The line is cb1:text(" "), so the problem might be that im using ":text" but on the wiki it states that checkboxes have that function.

    Full code

  • jacob1
    18th Feb 2015 Developer 0 Permalink
    On line 25 you have rBtn:action(refresh(1)), this is where it attemptd to run the refresh function before cb1 is defined. You probably meant rBtn:action(refresh).

    I'm not sure if you can put arguments into this function ... might have to make it call a separate function which calls refresh(1).
    Edited 2 times by jacob1. Last: 18th Feb 2015
  • derpyt
    18th Feb 2015 Member 0 Permalink

    @jacob1 (View Post)

     Thanks this worked :) i just made it so it runs another function which sets top_stack to 1 and then run refresh 

  • boxmein
    18th Feb 2015 Former Staff 0 Permalink
    ...There's a way to make what you want (pass the single argument onto the function but not call the function), it's sort of like Haskell's currying so I'll name it
    curry
    :

    function curry(f, a)
    return function()
    return f(a)
    end
    end


    However this function is only useful in your case where it only takes 1 value.
    So how you'd use it is this:

    rBtn:action(curry(refresh, 1))
    Edited once by boxmein. Last: 18th Feb 2015