Remove unneccesary argument
This commit is contained in:
parent
a58b1c9afe
commit
f4a75deba7
@ -206,29 +206,21 @@ impl PlayersWrapper {
|
||||
struct Context {
|
||||
#[rhai_type(skip)]
|
||||
commands: HashMap<String, FnPtr>,
|
||||
#[rhai_type(skip)]
|
||||
players: PlayersWrapper,
|
||||
}
|
||||
|
||||
impl Context {
|
||||
fn new(players: PlayersWrapper) -> Self {
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
commands: HashMap::new(),
|
||||
players,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn players(&mut self) -> PlayersWrapper {
|
||||
self.players.clone()
|
||||
}
|
||||
|
||||
fn register_command(&mut self, name: String, callback: FnPtr) {
|
||||
self.commands.insert(name, callback);
|
||||
}
|
||||
|
||||
fn build_extra(builder: &mut TypeBuilder<Self>) {
|
||||
builder.with_fn("Context", Self::new);
|
||||
builder.with_fn("players", Self::players);
|
||||
builder.with_fn("register_command", Self::register_command);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ fn metadata() {
|
||||
}
|
||||
|
||||
fn init(players) {
|
||||
let ctx = Context(players);
|
||||
let ctx = Context();
|
||||
ctx.register_command("jimmy", |player| {
|
||||
players.send_message(player, "He's dead")
|
||||
});
|
||||
|
@ -3,7 +3,7 @@ fn metadata() {
|
||||
}
|
||||
|
||||
fn init(players) {
|
||||
let ctx = Context(players);
|
||||
let ctx = Context();
|
||||
|
||||
ctx.register_command("ping", |player| {
|
||||
players.send_message(player, "pong")
|
||||
|
Loading…
Reference in New Issue
Block a user