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

相关文章

基于Go语言开发一个 IP 归属地查询接口工具

《基于Go语言开发一个IP归属地查询接口工具》在日常开发中,IP地址归属地查询是一个常见需求,本文将带大家使用Go语言快速开发一个IP归属地查询接口服务,有需要的小伙伴可以了解下... 目录功能目标技术栈项目结构核心代码(main.go)使用方法扩展功能总结在日常开发中,IP 地址归属地查询是一个常见需求:

基于 Cursor 开发 Spring Boot 项目详细攻略

《基于Cursor开发SpringBoot项目详细攻略》Cursor是集成GPT4、Claude3.5等LLM的VSCode类AI编程工具,支持SpringBoot项目开发全流程,涵盖环境配... 目录cursor是什么?基于 Cursor 开发 Spring Boot 项目完整指南1. 环境准备2. 创建

Python一次性将指定版本所有包上传PyPI镜像解决方案

《Python一次性将指定版本所有包上传PyPI镜像解决方案》本文主要介绍了一个安全、完整、可离线部署的解决方案,用于一次性准备指定Python版本的所有包,然后导出到内网环境,感兴趣的小伙伴可以跟随... 目录为什么需要这个方案完整解决方案1. 项目目录结构2. 创建智能下载脚本3. 创建包清单生成脚本4

SpringBoot 多环境开发实战(从配置、管理与控制)

《SpringBoot多环境开发实战(从配置、管理与控制)》本文详解SpringBoot多环境配置,涵盖单文件YAML、多文件模式、MavenProfile分组及激活策略,通过优先级控制灵活切换环境... 目录一、多环境开发基础(单文件 YAML 版)(一)配置原理与优势(二)实操示例二、多环境开发多文件版

使用docker搭建嵌入式Linux开发环境

《使用docker搭建嵌入式Linux开发环境》本文主要介绍了使用docker搭建嵌入式Linux开发环境,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面... 目录1、前言2、安装docker3、编写容器管理脚本4、创建容器1、前言在日常开发全志、rk等不同

Python实战之SEO优化自动化工具开发指南

《Python实战之SEO优化自动化工具开发指南》在数字化营销时代,搜索引擎优化(SEO)已成为网站获取流量的重要手段,本文将带您使用Python开发一套完整的SEO自动化工具,需要的可以了解下... 目录前言项目概述技术栈选择核心模块实现1. 关键词研究模块2. 网站技术seo检测模块3. 内容优化分析模

基于Java开发一个极简版敏感词检测工具

《基于Java开发一个极简版敏感词检测工具》这篇文章主要为大家详细介绍了如何基于Java开发一个极简版敏感词检测工具,文中的示例代码简洁易懂,感兴趣的小伙伴可以跟随小编一起学习一下... 目录你是否还在为敏感词检测头疼一、极简版Java敏感词检测工具的3大核心优势1.1 优势1:DFA算法驱动,效率提升10

Python开发简易网络服务器的示例详解(新手入门)

《Python开发简易网络服务器的示例详解(新手入门)》网络服务器是互联网基础设施的核心组件,它本质上是一个持续运行的程序,负责监听特定端口,本文将使用Python开发一个简单的网络服务器,感兴趣的小... 目录网络服务器基础概念python内置服务器模块1. HTTP服务器模块2. Socket服务器模块

Java 与 LibreOffice 集成开发指南(环境搭建及代码示例)

《Java与LibreOffice集成开发指南(环境搭建及代码示例)》本文介绍Java与LibreOffice的集成方法,涵盖环境配置、API调用、文档转换、UNO桥接及REST接口等技术,提供... 目录1. 引言2. 环境搭建2.1 安装 LibreOffice2.2 配置 Java 开发环境2.3 配

Python38个游戏开发库整理汇总

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