path other variable types to lua (except functions)
This commit is contained in:
parent
713977390d
commit
d988a10d9d
|
@ -112,19 +112,58 @@ mod enabled {
|
|||
Some(VariableData::MacroParameter { macro_name, .. }) => {
|
||||
Value::String(lua.create_string(format!("$({macro_name})"))?)
|
||||
}
|
||||
Some(VariableData::Scoreboard { objective }) => {
|
||||
let table = lua.create_table()?;
|
||||
table.set("objective", objective.as_str())?;
|
||||
Value::Table(table)
|
||||
}
|
||||
Some(VariableData::ScoreboardValue { objective, target }) => {
|
||||
let table = lua.create_table()?;
|
||||
table.set("objective", lua.create_string(objective)?)?;
|
||||
table.set("target", lua.create_string(target)?)?;
|
||||
Value::Table(table)
|
||||
}
|
||||
Some(VariableData::ScoreboardArray { objective, targets }) => {
|
||||
let table = lua.create_table()?;
|
||||
table.set("objective", objective.as_str())?;
|
||||
let values = lua.create_table_from(
|
||||
targets
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, target)| (i + 1, target.as_str())),
|
||||
)?;
|
||||
table.set("targets", values)?;
|
||||
Value::Table(table)
|
||||
}
|
||||
Some(VariableData::BooleanStorage { storage_name, path }) => {
|
||||
let table = lua.create_table()?;
|
||||
table.set("storage", lua.create_string(storage_name)?)?;
|
||||
table.set("path", lua.create_string(path)?)?;
|
||||
Value::Table(table)
|
||||
}
|
||||
Some(_) => todo!("allow other variable types"),
|
||||
Some(VariableData::BooleanStorageArray {
|
||||
storage_name,
|
||||
paths,
|
||||
}) => {
|
||||
let table = lua.create_table()?;
|
||||
table.set("storage", storage_name.as_str())?;
|
||||
let values = lua.create_table_from(
|
||||
paths
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, path)| (i + 1, path.as_str())),
|
||||
)?;
|
||||
table.set("paths", values)?;
|
||||
Value::Table(table)
|
||||
}
|
||||
Some(VariableData::Tag { tag_name }) => {
|
||||
let table = lua.create_table()?;
|
||||
table.set("name", tag_name.as_str())?;
|
||||
Value::Table(table)
|
||||
}
|
||||
Some(VariableData::Function { .. }) => {
|
||||
todo!("allow function variable type")
|
||||
}
|
||||
None => todo!("throw correct error"),
|
||||
};
|
||||
globals.set(name, value)?;
|
||||
|
|
Loading…
Reference in New Issue