饥荒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

相关文章

Python38个游戏开发库整理汇总

《Python38个游戏开发库整理汇总》文章介绍了多种Python游戏开发库,涵盖2D/3D游戏开发、多人游戏框架及视觉小说引擎,适合不同需求的开发者入门,强调跨平台支持与易用性,并鼓励读者交流反馈以... 目录PyGameCocos2dPySoyPyOgrepygletPanda3DBlenderFife

使用Python开发一个Ditto剪贴板数据导出工具

《使用Python开发一个Ditto剪贴板数据导出工具》在日常工作中,我们经常需要处理大量的剪贴板数据,下面将介绍如何使用Python的wxPython库开发一个图形化工具,实现从Ditto数据库中读... 目录前言运行结果项目需求分析技术选型核心功能实现1. Ditto数据库结构分析2. 数据库自动定位3

Django开发时如何避免频繁发送短信验证码(python图文代码)

《Django开发时如何避免频繁发送短信验证码(python图文代码)》Django开发时,为防止频繁发送验证码,后端需用Redis限制请求频率,结合管道技术提升效率,通过生产者消费者模式解耦业务逻辑... 目录避免频繁发送 验证码1. www.chinasem.cn避免频繁发送 验证码逻辑分析2. 避免频繁

Spring Boot集成/输出/日志级别控制/持久化开发实践

《SpringBoot集成/输出/日志级别控制/持久化开发实践》SpringBoot默认集成Logback,支持灵活日志级别配置(INFO/DEBUG等),输出包含时间戳、级别、类名等信息,并可通过... 目录一、日志概述1.1、Spring Boot日志简介1.2、日志框架与默认配置1.3、日志的核心作用

PyQt5 GUI 开发的基础知识

《PyQt5GUI开发的基础知识》Qt是一个跨平台的C++图形用户界面开发框架,支持GUI和非GUI程序开发,本文介绍了使用PyQt5进行界面开发的基础知识,包括创建简单窗口、常用控件、窗口属性设... 目录简介第一个PyQt程序最常用的三个功能模块控件QPushButton(按钮)控件QLable(纯文本

游戏闪退弹窗提示找不到storm.dll文件怎么办? Stormdll文件损坏修复技巧

《游戏闪退弹窗提示找不到storm.dll文件怎么办?Stormdll文件损坏修复技巧》DLL文件丢失或损坏会导致软件无法正常运行,例如我们在电脑上运行软件或游戏时会得到以下提示:storm.dll... 很多玩家在打开游戏时,突然弹出“找不到storm.dll文件”的提示框,随后游戏直接闪退,这通常是由于

基于Python开发一个图像水印批量添加工具

《基于Python开发一个图像水印批量添加工具》在当今数字化内容爆炸式增长的时代,图像版权保护已成为创作者和企业的核心需求,本方案将详细介绍一个基于PythonPIL库的工业级图像水印解决方案,有需要... 目录一、系统架构设计1.1 整体处理流程1.2 类结构设计(扩展版本)二、核心算法深入解析2.1 自

SpringBoot开发中十大常见陷阱深度解析与避坑指南

《SpringBoot开发中十大常见陷阱深度解析与避坑指南》在SpringBoot的开发过程中,即使是经验丰富的开发者也难免会遇到各种棘手的问题,本文将针对SpringBoot开发中十大常见的“坑... 目录引言一、配置总出错?是不是同时用了.properties和.yml?二、换个位置配置就失效?搞清楚加

Python中对FFmpeg封装开发库FFmpy详解

《Python中对FFmpeg封装开发库FFmpy详解》:本文主要介绍Python中对FFmpeg封装开发库FFmpy,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐... 目录一、FFmpy简介与安装1.1 FFmpy概述1.2 安装方法二、FFmpy核心类与方法2.1 FF

基于Python开发Windows屏幕控制工具

《基于Python开发Windows屏幕控制工具》在数字化办公时代,屏幕管理已成为提升工作效率和保护眼睛健康的重要环节,本文将分享一个基于Python和PySide6开发的Windows屏幕控制工具,... 目录概述功能亮点界面展示实现步骤详解1. 环境准备2. 亮度控制模块3. 息屏功能实现4. 息屏时间