summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/controls.rs8
-rw-r--r--src/systems/useitem.rs2
2 files changed, 9 insertions, 1 deletions
diff --git a/src/controls.rs b/src/controls.rs
index 581b522..3254e00 100644
--- a/src/controls.rs
+++ b/src/controls.rs
@@ -62,7 +62,13 @@ impl Control {
},
"take" => Some(Control::Take(val.get(1)?.as_u64().map(|idx| idx as usize))),
"drop" => Some(Control::Drop(val.get(1)?.as_u64().unwrap_or(0) as usize)),
- "use" => Some(Control::Use(val.get(1)?.as_u64().unwrap_or(0) as usize)),
+ "use" => Some({
+ println!("use argument {:?}", val);
+ if val.get(1)?.as_str()? != "inventory" {
+ return None;
+ }
+ Control::Use(val.get(2)?.as_u64().unwrap_or(0) as usize)
+ }),
"attack" => Some(Control::Attack({
let mut directions = Vec::new();
for dir in val.get(1)?.as_array()? {
diff --git a/src/systems/useitem.rs b/src/systems/useitem.rs
index 89a301c..43f38be 100644
--- a/src/systems/useitem.rs
+++ b/src/systems/useitem.rs
@@ -39,7 +39,9 @@ impl <'a> System<'a> for Use {
for (ent, controller, position, inventory) in (&entities, &controllers, &positions, &mut inventories).join(){
match &controller.control {
Control::Use(rank) => {
+ println!("rank {:?}", rank);
if let Some(item) = inventory.items.get(*rank) {
+ println!("rank {:?}", item);
match &item.action {
Build(template) => {
new.create(position.pos, template.clone()).unwrap();