local window = require("window") local entity = require("entity") local room = require("room") local edge = require("edge") local button = require("button") local seed = require("item/seed") local shelf = entity:from{ width = 60, height = 60, item = nil } shelf.draw = window.draw(function (self) love.graphics.setLineWidth(3) love.graphics.setColor(0, 0, 0) love.graphics.rectangle('fill', 0, 0, self.width, self.height) love.graphics.setColor(1, 1, 1) love.graphics.rectangle('line', 0, 0, self.width, self.height) if self.item then self.item:draw() end end) shelf.mousepressed = window.mousepressed(function (self, x, y, button) if self.item then inventory:pickup(self.item) self.item = nil self.item:setpos(20, 20) else local i = inventory.selected_item if i and i.name == "Seed" then self.item = i inventory:use() end end end) local indicator = entity:from{ width = 100, height = 20, text = "", } indicator.draw = window.draw(function (self) love.graphics.rectangle('line', 0, 0, self.width, self.height) love.graphics.printf(self.text, 5, 5, self.width - 10) end) local m = room:from{ state = 'normal', timer = 0, lines = {}, } local btn = button.new("Check", function () indicator.text = "Checking..." m.state = 'checking' end, 200, 120, 60, 30) function m:update(dt) if self.state == 'checking' then self.timer = self.timer + dt if self.timer > 5 then indicator.text = "done" self.state = 'normal' self.timer = 0 end end end m:insert(btn) indicator:install(m, 200, 90) seed:new():install(m, 150, 120) shelf:install(m, 60, 90) edge.set(m, 'down', "Vivarium") return m