Skip to content

Instantly share code, notes, and snippets.

@Mortimal
Last active February 23, 2017 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mortimal/ed7b1607c912550395efd99672ab0d01 to your computer and use it in GitHub Desktop.
Save Mortimal/ed7b1607c912550395efd99672ab0d01 to your computer and use it in GitHub Desktop.
#Parser.pm
elsif ($kw eq 'rndxy') {$ret = getRandomCoords($arg); $randomized = 1}
#Utilities.pm
sub getRandomCoords {
return ((int(rand(($_[0]+$_[2])-($_[0]-$_[2])+1))+($_[0]-$_[2]))." ".
(int(rand(($_[1]+$_[2])-($_[1]-$_[2])+1))+($_[1]-$_[2]))
) if (@_ = split(/,\s*/, $_[0])) or return "0 0";
}
# @rndxy(150,150,5)
# u get random <145to155> <145to155>
#
#
#
#
@allanon
Copy link

allanon commented Feb 23, 2017

sub getRandomCoords {
    return join ' ', (@_ = split /,/, $_[0]) ? ($_[0] - $_[2] + int rand 1 + 2 * $_[2], $_[1] - $_[2] + int rand 1 + 2 * $_[2]) : (0, 0);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment