I encountered a similar issue like this one: Hiding dynamically added buttons based on an if statement. I am currently working on a JavaScript modification for a Dark Room to enhance my JS skills. Both of the code snippets mentioned in the link are not mine, but they are functioning perfectly.
Below is the code snippet that builds the buttons:
build: function(buildBtn) {
var thing = $(buildBtn).attr('buildThing');
if($SM.get('game.temperature.value') <= Room.TempEnum.Cold.value) {
Notifications.notify(Room, _("builder just shivers"));
return false;
}
The above code snippet ensures that buttons remain visible, however, I am interested in modifying it so that when a certain maximum value is reached, the button gets hidden.
//show button if one has already been built
if($SM.get('game.buildings["'+thing+'"]') > 0){
Room.buttons[thing] = true;
return true;
}