Skip to content

Commit

Permalink
Implement loading/saving
Browse files Browse the repository at this point in the history
  • Loading branch information
fredley committed Aug 1, 2014
1 parent 2cc2bc8 commit 811334c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
11 changes: 11 additions & 0 deletions js/buttons.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,17 @@ init : function(){
}
}
});
// init button states
if(inventory.objects.blocks.wood.hasOwned){
$('#make-planks').show();
$('#inventory').show();
}
if(inventory.objects.blocks.planks.hasOwned){
$('#make-crafting').show();
}
if(inventory.objects.blocks.crafting_table.hasOwned){
$('#crafting').show();
}
this.hook_inventory();
},

Expand Down
1 change: 1 addition & 0 deletions js/inventory.js
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ var inventory = {
}
$('#inventory').html(inventoryText);
buttons.hook_inventory();
localStorage["objects"] = JSON.stringify(this.objects);
},

};
11 changes: 4 additions & 7 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
var main = {

onload : function(){

buttons.init();
inventory.init();

if('objects' in localStorage){
inventory.objects = JSON.parse(localStorage['objects']);
}
buttons.init();
window.setInterval(function(){main.tick()}, 1000);

// $(window).bind('beforeunload', function(){
// return "Are you sure you want to leave?"
// });
},

tick : function(){
Expand Down

0 comments on commit 811334c

Please sign in to comment.