Hail, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the Achaea Forums! Please be sure to read the Forum Rules.

Function Creation

TakuTaku Member Posts: 2
I know this question has been asked a thousand times and ive read many many forums posts on this in the past two days trying to get this to work but with no recourse. Mostly because there is no visual evidence of what I need to do and im tired of beating my head on a rock. So here we go.

Things I have tried:
Created my own onLoad function in my numpad/button package to load things
Used only the main package onload to create my function and call it from another package using different notation or even the run+script() function 
Calling functions in onLoad that were defined in the same package

Here is the code I have used so far in both ways: all of these were in the Code portion of the onLoad Function in Nexus --main package--

let up_down = ['UP','DOWN']
let left_right = ['LEFT','RIGHT']
let compass = ['NORTH','SOUTH','EAST','WEST','SOUTHWEST','SOUTHEAST','NORTHWEST','NORTHEAST']

function random_output(input){
    let RandListNum = Math.floor(Math.random()*input.length);
    return input[RandListNum]
 }


I also tried this relating to this question:  http://forums.achaea.com/discussion/5577/attaching-named-functions-to-buttons

(function) onLoad:

let up_down = ['UP','DOWN']
let left_right = ['LEFT','RIGHT']
let compass = ['NORTH','SOUTH','EAST','WEST','SOUTHWEST','SOUTHEAST','NORTHWEST','NORTHEAST']

function random_output(input){
    let RandListNum = Math.floor(Math.random()*input.length);
    return input[RandListNum]
 }


so if I wanted to do a CompassSlash to someone via keybind, alias, or however I would want to the inside of the code part should resemble

send_command("Compassslash "+ random_output(compass)) 

But I receive nothing but input is not defined. I even tried the whole (function) onLoad in the script body of the send_commands as well with no avail. Any help please? 

Sorry if I seem a bit annoyed, this should be fairly simple.
Tagged:

Comments

  • ChubbsChubbs Member Posts: 65 ✭✭✭ - Distinguished
    Sooooo.... pretty sure it works if you do this instead when you make that random_output function.

    random_output = function(input){
        let RandListNum = Math.floor(Math.random()*input.length);
        return input[RandListNum]
     }
    Taku
  • TakuTaku Member Posts: 2
    edited December 2017
    Okay I think I got things to work a bit differently and at least somewhat...now in a way I want.. why is that not JS syntax.. 
Sign In to Comment.