Skip to content

Instantly share code, notes, and snippets.

@Ameliorate
Ameliorate / fn.rs
Created March 30, 2016 22:22
Hlua no functions with arguments workaround
/// Call the given lua function in the prelude table with the given arguments.
pub fn call_fn(interpreter: &mut Lua,
fn_to_call: &str,
args: Vec<AnyLuaValue>)
-> Result<Option<AnyLuaValue>, LuaError> {
let mut prelude_table: LuaTable<_> = interpreter
.get("prelude")
.expect("The prelude_table wasn't found. Was \
the prelude properly loaded?");
prelude_table.set("fn_to_call", fn_to_call);
//! Example of graph-based neural network thing.
use std::collections::HashMap;
use std::ops::Deref;
use std::rc::Rc;
struct NodeNeuralNetwork {
// The nodes and connections are a Vec so that you can access them randomly during the mutation phase.
nodes: Vec<Box<Node>>,
connections: Vec<Connection>,
var mf = require('mineflayer');
var rp = require('mineflayer-radar')(mf);
var c = require('./config.js');
var d = require('discord.js');
var h = require('humanize');
b = mf.createBot({
host: c.host,
port: c.port,
username: c.username,
dungeons:
testdungeon:
type: DecayDungeon
spawnX: 2
spawnY: 2
spawnZ: 2
exitX: 0
exitY: 128
exitZ: 0
maxX: 100
portals:
testdungeon1:
type: BlockInteract
entryOrExit: entry
rightclick: true
leftclick: false
cancelEvent: true
material: LEVER
x1: 0
y1: 32
dungeons:
exampledungeon:
spawnX: 10
spawnY: 16
spawnZ: 43
# Other options omitted
dungeons:
reallyquitebigdungeon:
# You probably shouldn't have this large of a dungeon, since it will take a long time to generate the first time around.
# Also if it's a DecayDungeon it'll take even longer, since each time the server starts every single block has to be
# copied over from the template, which tends to be slow for large dungeons.
maxX: 150
maxY: 200
maxZ: 59