//* comment *// Copyright (C) 2015 Ignacio Rodríguez This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . TODO: description //* globals *// var nutritionCalories = 0; var nutritionProtein = 0; var nutritionCarbohydrate = 0; var nutritionFiber = 0; var nutritionFat = 0; var nutritionFoodData = { 'apple': [72, 0, 19, 3, 0], 'banana': [105, 1, 27, 3, 0], 'orange': [62, 1, 15, 3, 0], 'bread': [69, 4, 12, 2, 1], 'corn': [96, 3, 21, 3, 1], 'potato': [159, 4, 36, 4, 0], 'sweetpotato': [169, 1, 22, 1, 8], 'tomato': [150, 4, 25, 3, 5], 'broccoli': [94, 4, 11, 5, 5], 'riceandbeans': [411, 14, 60, 8, 13], 'tamale': [126, 6, 11, 1, 6], 'cheese': [114, 7, 0, 0, 9], 'chicken': [152, 15, 0, 0, 10], 'fish': [58, 6, 0, 0, 3], 'beef': [285, 46, 0, 0, 10], 'cake': [387, 4, 69, 2, 13], 'cookie': [68, 1, 8, 0, 4], 'water': [0, 0, 0, 0, 0] }; //* flow-globals *// var block = logo.blocks.blockList[blk]; var conns = block.connections; function showMsg(data) { logo.textMsg(JSON.stringify(data)); }; //* arg-globals *// var block = logo.blocks.blockList[blk]; var conns = block.connections; //* block-globals *// var get_eatme = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgMathBlock(); block.dockTypes[1] = 'mediain'; }; var show_value = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.parameterBlock(); }; var eat = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.oneArgBlock(); block.dockTypes[1] = 'mediain'; }; var action = function (name, label) { var block = new ProtoBlock(name); block.palette = palettes.dict['eatme']; blocks.protoBlockDict[name] = block; block.staticLabels.push(label); block.adjustWidthToLabel(); block.zeroArgBlock(); }; var food_block = function (blkname, name) { var block = new ProtoBlock(blkname); block.palette = palettes.dict['food']; block.image = pluginsImages[blkname]; block.staticLabels.push(name); block.adjustWidthToLabel(); block.mediaBlock(); blocks.protoBlockDict[blkname] = block; }; //* block:get_calories *// get_eatme('get_calories', _('get calories')); //* block:get_protein *// get_eatme('get_protein', _('get protein')); //* block:get_carbohydrates *// get_eatme('get_carbohydrates', _('get carbs')); //* block:get_fiber *// get_eatme('get_fiber', _('get fiber')); //* block:get_fat *// get_eatme('get_fat', _('get fat')); //* block:get_name *// get_eatme('get_name', _('get name')); //* block:calories *// show_value('calories', _('calories')); //* parameter:calories )*// value = nutritionCalories; //* block:protein *// show_value('protein', _('protein')); //* parameter:protein *// value = nutritionProtein; //* block:carbohydrates *// show_value('carbohydrates', _('carbs')); //* parameter:carbohydrates *// value = nutritionCarbohydrates; //* block:fiber *// show_value('fiber', _('fiber')); //* parameter:fiber *// value = nutritionFiber; //* block:fat *// show_value('fat', _('fat')); //* parameter:fat *// value = nutritionFat; //* block:eat *// eat('eat', _('eat')); //* block:digest *// action('digest', _('digest meal'), 20); //* block:apple *// food_block('apple', _('apple')); //* block:banana *// food_block('banana', _('banana')); //* block:orange *// food_block('orange', _('orange')); //* block:bread *// food_block('bread', _('wheat bread')); //* block:corn *// food_block('corn', _('corn')); //* block:potato *// food_block('potato', _('potato')); //* block:sweetpotato *// food_block('sweetpotato', _('sweet potato')); //* block:tomato *// food_block('tomato', _('tomato')); //* block:broccoli *// food_block('broccoli', _('broccoli')); //* block:riceandbeans *// food_block('riceandbeans', _('rice and beans')); //* block:tamale *// food_block('tamale', _('tamale')); //* block:cheese *// food_block('cheese', _('cheese')); //* block:chicken *// food_block('chicken', _('chicken')); //* block:fish *// food_block('fish', _('fish')); //* block:beef *// food_block('beef', _('beef')); //* block:cake *// food_block('cake', _('cake')); //* block:cookie *// food_block('cookie', _('cookie')); //* block:water *// food_block('water', _('water')); //* flow:apple *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:banana *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:orange *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:bread *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:corn *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:potato *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:sweetpotato *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:tomato *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:broccoli *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:riceandbeans *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:tamale *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:cheese *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:chicken *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:fish *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:beef *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:cake *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:cookie *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:water *// block.value = nutritionFoodData[block.name]; showMsg(block.value); //* flow:eat *// console.log(); var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name]; nutritionCalories += blockFoodData[0]; nutritionProtein += blockFoodData[1]; nutritionCarbohydrate += blockFoodData[2]; nutritionFiber += blockFoodData[3]; nutritionFat += blockFoodData[4]; //* flow:digest *// nutritionCalories = 0; nutritionProtein = 0; nutritionCarbohydrate = 0; nutritionFiber = 0; nutritionFat = 0; //* arg:fiber *// block.value = nutritionFiber; //* arg:calories *// block.value = nutritionCalories; //* arg:protein *// block.value = nutritionProtein; //* arg:carbohydrates *// block.value = nutritionCarbohydrate; //* arg:fat *// block.value = nutritionFat; //* arg:get_calories *// var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name]; block.value = blockFoodData[0]; //* arg:get_protein *// var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name]; block.value = blockFoodData[1]; //* arg:get_carbohydrates *// var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name]; block.value = blockFoodData[2]; //* arg:get_fiber *// var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name]; block.value = blockFoodData[3]; //* arg:get_fat *// var blockFoodData = nutritionFoodData[logo.blocks.blockList[conns[1]].name]; block.value = blockFoodData[4]; //* arg:get_name *// block.value = logo.blocks.blockList[conns[1]].name; //* palette-icon:food *// //* palette-fill:food *// #D5D5D5 //* palette-stroke:food *// #A0A0A0 //* palette-highlight:food *// #FFFFFF //* palette-stroke-highlight:food *// #000000 //* palette-icon:eatme *// //* palette-fill:eatme *// #D5D5D5 //* palette-stroke:eatme *// #A0A0A0 //* palette-highlight:eatme *// #FFFFFF //* palette-stroke-highlight:eatme *// #000000 //* image:egg *// //* image:orange *// //* image:tomato *// //* image:sweetpotato *// //* image:broccoli *// //* image:apple *// //* image:cookie *// //* image:corn *// //* image:water *// //* image:beef *// //* image:cake *// //* image:potato *// //* image:fish *// //* image:bread *// //* image:banana *// //* image:cheese *// //* image:chicken *// //* image:tamale *// //* image:riceandbeans *//