饥荒Mod 开发(八):游戏所有食材和食物

2023-12-07 16:20

本文主要是介绍饥荒Mod 开发(八):游戏所有食材和食物,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

饥荒中内置了很多烹饪的食物,每种食物都可以由不同的食材烹饪出来,今天介绍如何将内置的食物打印出来。

食材

饥荒中的食材可以放入烹饪锅,每个食材都有很多的属性,比如名字,类型,“度数”

-- 为 "meat" 这个食材添加 "meat" 属性,属性的值是 1。
AddIngredientValues({"meat"}, {meat=1}, true, true)-- 为 "monstermeat" 这个食材添加 "meat" 和 "monster" 两个属性,每个属性的值都是 1。
AddIngredientValues({"monstermeat"}, {meat=1, monster=1}, true, true)-- 为 "froglegs"、"drumstick" 和 "batwing" 这些食材添加 "meat" 属性,属性的值是 0.5。
AddIngredientValues({"froglegs", "drumstick", "batwing"}, {meat=.5}, true)-- 为 "smallmeat" 这个食材添加 "meat" 属性,属性的值是 0.5。
AddIngredientValues({"smallmeat"}, {meat=.5}, true, true)-- 为 "plantmeat" 这个食材添加 "meat" 属性,属性的值是 1。
AddIngredientValues({"plantmeat"}, {meat=1}, true)

在这里插入图片描述
我们也可以调用AddIngredientValues 添加自己的食材

食谱

游戏有一个lua代码文件定义了很多的内置食物。每种食物的烹饪时间,食物类型,生命/节/精神值,以及保鲜时间等。代码路径如下:
data\scripts\preparedfoods.lua

--部分代码解释
butterflymuffin =
{-- test 是一个函数,用于检查是否可以制作这个食物。-- 这个函数接受三个参数:cooker(烹饪设备),names(食材的名称),tags(食材的标签)。-- 这个函数返回 true 如果食材中包含蝴蝶翅膀,不包含肉类,并且包含蔬菜。test = function(cooker, names, tags) return names.butterflywings and not tags.meat and tags.veggie end,-- priority 决定了在多个配方都可以制作的情况下,哪个配方会被优先选择。数字越大,优先级越高。priority = 1,-- weight 决定了这个食物的重量,可能影响角色移动速度。weight = 1,-- foodtype 是这个食物的类型,这里是 "VEGGIE",表示这是一个蔬菜类食物。foodtype = "VEGGIE",-- health,hunger,sanity 分别表示这个食物恢复的生命值,饥饿值和精神值。health = TUNING.HEALING_MED,hunger = TUNING.CALORIES_LARGE,sanity = TUNING.SANITY_TINY,-- perishtime 是这个食物的腐烂时间,单位是天。perishtime = TUNING.PERISH_SLOW,-- cooktime 是这个食物的烹饪时间,实际 2 *20 秒。cooktime = 2,
},

食物

如何判断烹饪的结果

饥荒中判断烹饪结果是通过食物的test函数来判断的,当我们放入4个原料的时候,游戏会按照优先级遍历所有的食物,挨个调用test函数,只要test函数返回true,就认为可以烹饪。所以不同的原料是可以烹饪出相同的食物的。
饥荒提供了一个函数用来判断烹饪结果。源码在:data\scripts\cooking.lua

-- 引入 cooking 模块
local cooking = require("cooking")-- 创建一个表来存储食材
local ings = {}-- 向食材表中添加四个 "twigs"
table.insert(ings, "twigs")
table.insert(ings, "twigs")
table.insert(ings, "twigs")
table.insert(ings, "twigs")-- 调用 cooking.CalculateRecipe 函数来计算烹饪的结果和所需的时间
-- "cookpot" 是烹饪设备的类型,ings 是食材表
-- CalculateRecipe 函数返回两个值:烹饪的结果(product)和所需的时间(cooktime)
local product, cooktime = cooking.CalculateRecipe("cookpot", ings)

输出饥荒中所有的食材和食物

在modmain.lua 文件中,复制下面的代码。进入以后洗之后,打开调试页面, 按下键盘F1 键盘,可以将结果输出到文件中,文件的目录比较深,可以用everything 搜索一下,我的路径

C:\WeGameApps\rail_user_data\2000013\76561197981883591\cloud_storage\user_space\2199037600743566342\formal\content\files\myfoods.txt
-- 导入 "cooking" 模块,这个模块包含了食材和食谱的定义。
local cooking = GLOBAL.require("cooking")-- 添加一个按键处理器。这个处理器会在玩家按下或释放一个键时被调用。
GLOBAL.TheInput:AddKeyHandler(function(key, down)-- 检查按下的键是否是 F1 键if (key == GLOBAL.KEY_F1 and not down) thenlocal content = "-----------------原料------------------------"-- 遍历所有的食材。for name, v in pairs(cooking.ingredients) do-- 将食材的名称添加到 content 字符串中。content = content .. tostring(GLOBAL.STRINGS.NAMES[string.upper(name)]) .. "(" .. name .. ")\n"-- 如果这个食材有标签,那么遍历这些标签,并将它们添加到 content 字符串中。if v.tags then              for tag, tagval in pairs(v.tags) docontent = content .. tag .. ":" .. tostring(tagval) .. "\t"endendcontent = content .. "\n"end-- 遍历所有的食谱。content = content .. "-----------------食谱------------------------\n"for cooker, v in pairs(cooking.recipes) do-- 将烹饪设备的名称添加到 content 字符串中。content = content .. cooker .. "\n"-- 遍历这个烹饪设备可以制作的所有食物,并将这些食物的信息添加到 content 字符串中。for name, recipe in pairs(v) docontent = content .. tostring(GLOBAL.STRINGS.NAMES[string.upper(name)]) .. "("..  name .. "):" .. " foodtype:" .. tostring(recipe.foodtype) .. " health:" .. tostring(recipe.health) .. " hunger:" .. tostring(recipe.hunger) .. " sanity:" .. tostring(recipe.sanity) .. " \n\n"endcontent = content .. "\n"end-- 将 content 字符串保存到 "myfoods.txt" 文件中。TheSim:SetPersistentString("myfoods.txt", content)	end
end)
KLEI     1 -----------------原料------------------------蝴蝶翅膀(butterflywings)
decoration:2	熟红蘑菇(red_cap_cooked)
veggie:0.5	precook:1	烤椰子(coconut_cooked)
fruit:1	fat:1	洞穴蝙蝠翅膀(batwing)
meat:0.5	龙虾(lobster)
fish:2	熟甘薯(sweet_potato_cooked)
veggie:1	precook:1	采摘的绿蘑菇(green_cap)
veggie:0.5	鱼(fish)
meat:0.5	fish:1	熟蛙腿(froglegs_cooked)
meat:0.5	precook:1	鼹鼠(mole)
meat:0.5	茄子(eggplant)
veggie:1	榴莲(durian)
monster:1	fruit:1	烤咖啡豆(coffeebeans_cooked)
fruit:1	熟火龙果(dragonfruit_cooked)
fruit:1	precook:1	晾干的水母(jellyjerky)
monster:1	fish:1	jellyfish:1	熟鳗鱼(eel_cooked)
fish:1	meat:0.5	precook:1	采摘的蓝蘑菇(blue_cap)
veggie:0.5	生鱼肉(fish_raw)
meat:0.5	fish:1	nil(monstermeat_cooked)
monster:1	meat:1	precook:1	干海带(seaweed_dried)
dried:1	veggie:1	nil(smallmeat_cooked)
meat:0.5	precook:1	高脚鸟蛋(tallbirdegg)
egg:4	nil(egg_cooked)
egg:1	precook:1	冰(ice)
frozen:1	熟水母(jellyfish_cooked)
monster:1	fish:1	jellyfish:1	鱼翅(shark_fin)
meat:0.5	fish:1	烤桦栗果(acorn_cooked)
seed:1	precook:1	烤茄子(eggplant_cooked)
veggie:1	precook:1	分成两半的椰子(coconut_halved)
fruit:1	fat:1	nil(meat_cooked)
meat:1	precook:1	浆果(berries)
fruit:0.5	蜂蜜(honey)
sweetener:1	热带鱼(tropical_fish)
meat:0.5	fish:1	熟小丑鱼(fish4_cooked)
meat:0.5	fish:1	仙人掌花(cactus_flower)
veggie:0.5	熟小鱼块(fish_raw_small_cooked)
fish:0.5	precook:1	曼德拉草(mandrake)
magic:1	veggie:1	蜂巢(honeycomb)
sweetener:1	洞穴香蕉(cave_banana)
fruit:1	咖啡豆(coffeebeans)
fruit:0.5	兔蟹(crab)
fish:0.5	nil(lobster_cooked)
fish:2	precook:1	熟贻贝(mussel_cooked)
fish:0.5	precook:1	鸟蛋(bird_egg)
egg:1	贻贝(mussel)
fish:0.5	熟帽贝(limpets_cooked)
fish:0.5	precook:1	小丑鱼(fish4)
meat:0.5	fish:1	死狗鱼(fish_med)
meat:0.5	fish:1	鱼卵(roe)
meat:0.5	fish:1	帽贝(limpets)
fish:0.5	蛙腿(froglegs)
meat:0.5	熟彩虹水母(rainbowjellyfish_cooked)
monster:1	fish:1	jellyfish:1	炸鸟腿(drumstick_cooked)
meat:0.5	precook:1	死彩虹水母(rainbowjellyfish_dead)
monster:1	fish:1	jellyfish:1	熟鸟蛋(bird_egg_cooked)
egg:1	precook:1	彩虹水母(rainbowjellyfish)
monster:1	fish:1	jellyfish:1	鳗鱼(eel)
meat:0.5	fish:1	烤胡萝卜(carrot_cooked)
veggie:1	precook:1	小肉(smallmeat)
meat:0.5	死水母(jellyfish_dead)
monster:1	fish:1	jellyfish:1	水母(jellyfish)
monster:1	fish:1	jellyfish:1	超臭榴莲(durian_cooked)
monster:1	fruit:1	precook:1	熟鱼卵(roe_cooked)
meat:0.5	fish:1	熟霓虹鱼(fish5_cooked)
meat:0.5	fish:1	霓虹鱼(fish5)
meat:0.5	fish:1	熟紫石斑鱼(fish3_cooked)
meat:0.5	fish:1	切片熟石榴(pomegranate_cooked)
fruit:1	precook:1	肉干(meat_dried)
dried:1	meat:1	nil(honey_cooked)
sweetener:1	precook:1	树枝(twigs)
inedible:1	熟绿蘑菇(green_cap_cooked)
veggie:0.5	precook:1	南瓜(pumpkin)
veggie:1	nil(tropical_fish_cooked)
fish:1	meat:0.5	precook:1	剑鱼(swordfish)
meat:0.5	fish:1	熟叶肉(plantmeat_cooked)
meat:1	precook:1	胡萝卜(carrot)
veggie:1	鱼排(fish_med_cooked)
meat:0.5	fish:1	背鳍(dorsalfin)
inedible:1	西瓜(watermelon)
fruit:1	渡渡鸟蛋(doydoyegg)
egg:1	熟蓝蘑菇(blue_cap_cooked)
veggie:0.5	precook:1	熟鱼(fish_cooked)
fish:1	meat:0.5	precook:1	烤海带(seaweed_cooked)
veggie:1	precook:1	小鱼块(fish_raw_small)
fish:0.5	玉米(corn)
veggie:1	叶肉(plantmeat)
meat:1	带电的羊奶(goatmilk)
dairy:1	桦栗果(acorn)
seed:1	烤西瓜(watermelon_cooked)
fruit:1	precook:1	nil(honeycomb_cooked)
sweetener:1	precook:1	煎渡渡鸟蛋(doydoyegg_cooked)
egg:1	precook:1	苔藓(cutlichen)
veggie:1	仙人掌肉(cactus_meat)
veggie:1	nil(egg)
egg:1	熟蝙蝠翅膀(batwing_cooked)
meat:0.5	precook:1	怪物肉(monstermeat)
meat:1	monster:1	火龙果(dragonfruit)
fruit:1	紫石斑鱼(fish3)
meat:0.5	fish:1	烤南瓜(pumpkin_cooked)
veggie:1	precook:1	肉(meat)
meat:1	海带(seaweed)
veggie:1	烤浆果(berries_cooked)
fruit:0.5	precook:1	鸟腿(drumstick)
meat:0.5	石榴(pomegranate)
fruit:1	熟仙人掌肉(cactus_meat_cooked)
veggie:1	precook:1	黄油(butter)
dairy:1	fat:1	nil(mandrake_cooked)
veggie:1	magic:1	precook:1	甘薯(sweet_potato)
veggie:1	熟香蕉(cave_banana_cooked)
fruit:1	precook:1	怪物肉干(monstermeat_dried)
dried:1	meat:1	monster:1	小风干肉(smallmeat_dried)
dried:1	meat:0.5	爆米花(corn_cooked)
veggie:1	precook:1	nil(cutlichen_cooked)
veggie:1	precook:1	煎高脚鸟蛋(tallbirdegg_cooked)
egg:4	precook:1	采摘的红蘑菇(red_cap)
veggie:0.5	-----------------食谱------------------------
portablecookpot
贻贝浓汤(musselbouillabaise): foodtype:MEAT health:20 hunger:37.5 sanity:15 怪物鞑靼(monstertartare): foodtype:MEAT health:3 hunger:37.5 sanity:10 甘薯蛋奶酥(sweetpotatosouffle): foodtype:VEGGIE health:20 hunger:37.5 sanity:15 鲜果可丽饼(freshfruitcrepes): foodtype:VEGGIE health:60 hunger:150 sanity:15 cookpot
香蕉冻(bananapop): foodtype:VEGGIE health:20 hunger:12.5 sanity:33 热带鱼汤(tropicalbouillabaisse): foodtype:MEAT health:20 hunger:37.5 sanity:15 鲜贝浓汤(bisque): foodtype:MEAT health:60 hunger:18.75 sanity:5 怪物千层饼(monsterlasagna): foodtype:MEAT health:-20 hunger:37.5 sanity:-20 酸橘汁腌鱼(ceviche): foodtype:MEAT health:20 hunger:25 sanity:5 蛙腿三明治(frogglebunwich): foodtype:MEAT health:20 hunger:37.5 sanity:5 水母冻(jellyopop): foodtype:MEAT health:20 hunger:12.5 sanity:0 南瓜饼干(pumpkincookie): foodtype:VEGGIE health:0 hunger:37.5 sanity:15 潮湿黏糊(wetgoop): foodtype:nil health:0 hunger:0 sanity:0 鳗鱼料理(unagi): foodtype:MEAT health:20 hunger:18.75 sanity:5 火鸡正餐(turkeydinner): foodtype:MEAT health:20 hunger:75 sanity:5 炸鱼排(fishsticks): foodtype:MEAT health:40 hunger:37.5 sanity:5 曼德拉草汤(mandrakesoup): foodtype:VEGGIE health:100 hunger:150 sanity:5 培根煎蛋(baconeggs): foodtype:MEAT health:20 hunger:75 sanity:5 鱼翅汤(sharkfinsoup): foodtype:MEAT health:40 hunger:12.5 sanity:-10 华夫饼(waffles): foodtype:VEGGIE health:60 hunger:37.5 sanity:5 辣椒炖肉(hotchili): foodtype:MEAT health:20 hunger:37.5 sanity:0 水果圣代(fruitmedley): foodtype:VEGGIE health:20 hunger:25 sanity:5 西瓜冰棍(watermelonicle): foodtype:VEGGIE health:3 hunger:12.5 sanity:20 芝士蛋糕(powcake): foodtype:VEGGIE health:-3 hunger:0 sanity:0 加州卷(californiaroll): foodtype:MEAT health:20 hunger:37.5 sanity:10 龙虾汤(lobsterbisque): foodtype:MEAT health:60 hunger:25 sanity:10 蔬菜杂烩(ratatouille): foodtype:VEGGIE health:3 hunger:25 sanity:5 鱼肉玉米卷(fishtacos): foodtype:MEAT health:20 hunger:37.5 sanity:5 炖肉汤(bonestew): foodtype:MEAT health:12 hunger:150 sanity:5 鱼子酱(caviar): foodtype:MEAT health:3 hunger:12.5 sanity:33 肉丸(meatballs): foodtype:MEAT health:3 hunger:62.5 sanity:5 蝴蝶松饼(butterflymuffin): foodtype:VEGGIE health:20 hunger:37.5 sanity:5 冰淇淋(icecream): foodtype:VEGGIE health:0 hunger:25 sanity:50 果酱(jammypreserves): foodtype:VEGGIE health:3 hunger:37.5 sanity:5 海鲜牛排(surfnturf): foodtype:MEAT health:60 hunger:37.5 sanity:33 酿茄子(stuffedeggplant): foodtype:VEGGIE health:3 hunger:37.5 sanity:5 鳄梨酱(guacamole): foodtype:MEAT health:20 hunger:37.5 sanity:0 蜜汁卤肉(honeynuggets): foodtype:MEAT health:20 hunger:37.5 sanity:5 海鲜浓汤(seafoodgumbo): foodtype:MEAT health:40 hunger:37.5 sanity:20 什锦干果(trailmix): foodtype:VEGGIE health:30 hunger:12.5 sanity:5 龙虾正餐(lobsterdinner): foodtype:MEAT health:60 hunger:37.5 sanity:50 太妃糖(taffy): foodtype:VEGGIE health:-3 hunger:25 sanity:15 波兰水饺(perogies): foodtype:MEAT health:40 hunger:37.5 sanity:5 火龙果派(dragonpie): foodtype:VEGGIE health:40 hunger:75 sanity:5 肉串(kabobs): foodtype:MEAT health:3 hunger:37.5 sanity:5 花沙拉(flowersalad): foodtype:VEGGIE health:40 hunger:12.5 sanity:5 咖啡(coffee): foodtype:VEGGIE health:3 hunger:9.375 sanity:-5 蜜汁火腿(honeyham): foodtype:MEAT health:30 hunger:75 sanity:5 

这篇关于饥荒Mod 开发(八):游戏所有食材和食物的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/466524

相关文章

这15个Vue指令,让你的项目开发爽到爆

1. V-Hotkey 仓库地址: github.com/Dafrok/v-ho… Demo: 戳这里 https://dafrok.github.io/v-hotkey 安装: npm install --save v-hotkey 这个指令可以给组件绑定一个或多个快捷键。你想要通过按下 Escape 键后隐藏某个组件,按住 Control 和回车键再显示它吗?小菜一碟: <template

Hadoop企业开发案例调优场景

需求 (1)需求:从1G数据中,统计每个单词出现次数。服务器3台,每台配置4G内存,4核CPU,4线程。 (2)需求分析: 1G / 128m = 8个MapTask;1个ReduceTask;1个mrAppMaster 平均每个节点运行10个 / 3台 ≈ 3个任务(4    3    3) HDFS参数调优 (1)修改:hadoop-env.sh export HDFS_NAMENOD

嵌入式QT开发:构建高效智能的嵌入式系统

摘要: 本文深入探讨了嵌入式 QT 相关的各个方面。从 QT 框架的基础架构和核心概念出发,详细阐述了其在嵌入式环境中的优势与特点。文中分析了嵌入式 QT 的开发环境搭建过程,包括交叉编译工具链的配置等关键步骤。进一步探讨了嵌入式 QT 的界面设计与开发,涵盖了从基本控件的使用到复杂界面布局的构建。同时也深入研究了信号与槽机制在嵌入式系统中的应用,以及嵌入式 QT 与硬件设备的交互,包括输入输出设

OpenHarmony鸿蒙开发( Beta5.0)无感配网详解

1、简介 无感配网是指在设备联网过程中无需输入热点相关账号信息,即可快速实现设备配网,是一种兼顾高效性、可靠性和安全性的配网方式。 2、配网原理 2.1 通信原理 手机和智能设备之间的信息传递,利用特有的NAN协议实现。利用手机和智能设备之间的WiFi 感知订阅、发布能力,实现了数字管家应用和设备之间的发现。在完成设备间的认证和响应后,即可发送相关配网数据。同时还支持与常规Sof

活用c4d官方开发文档查询代码

当你问AI助手比如豆包,如何用python禁止掉xpresso标签时候,它会提示到 这时候要用到两个东西。https://developers.maxon.net/论坛搜索和开发文档 比如这里我就在官方找到正确的id描述 然后我就把参数标签换过来

Linux_kernel驱动开发11

一、改回nfs方式挂载根文件系统         在产品将要上线之前,需要制作不同类型格式的根文件系统         在产品研发阶段,我们还是需要使用nfs的方式挂载根文件系统         优点:可以直接在上位机中修改文件系统内容,延长EMMC的寿命         【1】重启上位机nfs服务         sudo service nfs-kernel-server resta

【区块链 + 人才服务】区块链集成开发平台 | FISCO BCOS应用案例

随着区块链技术的快速发展,越来越多的企业开始将其应用于实际业务中。然而,区块链技术的专业性使得其集成开发成为一项挑战。针对此,广东中创智慧科技有限公司基于国产开源联盟链 FISCO BCOS 推出了区块链集成开发平台。该平台基于区块链技术,提供一套全面的区块链开发工具和开发环境,支持开发者快速开发和部署区块链应用。此外,该平台还可以提供一套全面的区块链开发教程和文档,帮助开发者快速上手区块链开发。

Vue3项目开发——新闻发布管理系统(六)

文章目录 八、首页设计开发1、页面设计2、登录访问拦截实现3、用户基本信息显示①封装用户基本信息获取接口②用户基本信息存储③用户基本信息调用④用户基本信息动态渲染 4、退出功能实现①注册点击事件②添加退出功能③数据清理 5、代码下载 八、首页设计开发 登录成功后,系统就进入了首页。接下来,也就进行首页的开发了。 1、页面设计 系统页面主要分为三部分,左侧为系统的菜单栏,右侧

v0.dev快速开发

探索v0.dev:次世代开发者之利器 今之技艺日新月异,开发者之工具亦随之进步不辍。v0.dev者,新兴之开发者利器也,迅速引起众多开发者之瞩目。本文将引汝探究v0.dev之基本功能与优势,助汝速速上手,提升开发之效率。 何谓v0.dev? v0.dev者,现代化之开发者工具也,旨在简化并加速软件开发之过程。其集多种功能于一体,助开发者高效编写、测试及部署代码。无论汝为前端开发者、后端开发者

国产游戏崛起:技术革新与文化自信的双重推动

近年来,国产游戏行业发展迅猛,技术水平和作品质量均得到了显著提升。特别是以《黑神话:悟空》为代表的一系列优秀作品,成功打破了过去中国游戏市场以手游和网游为主的局限,向全球玩家展示了中国在单机游戏领域的实力与潜力。随着中国开发者在画面渲染、物理引擎、AI 技术和服务器架构等方面取得了显著进展,国产游戏正逐步赢得国际市场的认可。然而,面对全球游戏行业的激烈竞争,国产游戏技术依然面临诸多挑战,未来的