sims算法_Sims 4 Modern Python Modding第5部分扩展列表

sims算法

This is going to be a much easier and shorter tutorial and a bit more fun. You’re going to learn how to extend an in-game list. Extending a list is much safer because it’s often the least likely to conflict with other mods because we’re not replacing anything yet can add additional options or functionality to the entire game.

这将是一个更容易,更简短的教程,并且更加有趣。 您将学习如何扩展游戏清单。 扩展列表更加安全,因为它通常与其他模块冲突的可能性最小,因为我们不替换任何东西,但可以在整个游戏中添加其他选项或功能。

As briefly mentioned in part 4, there’s an official list of words/strings considered to be “true” and another list for “false”. These 2 lists are used in any command that takes a yes or no / true or false argument. Most mods don’t seem to use the list unfortunately but any that do will automatically be using the extended list. For this tutorial, we’re going to extend both of those lists.

第4部分所述,有一个正式的单词/字符串列表被认为是“ true”,另一个列表是“ false”。 这两个列表可用于任何接受yes或no / true或false参数的命令。 不幸的是,大多数mod似乎并没有使用该列表,但是任何使用它的人都会自动使用扩展列表。 对于本教程,我们将扩展这两个列表。

确保您从第1部分开始 (Make sure you start at part 1)

The projects here assume your up-to-speed on how to mod for the Sims 4 using python scripting which I already covered in part 1 & part 2.

此处的项目假定您已掌握如何使用python脚本修改Sims 4的最新信息,我已经在第1部分第2部分中进行了介绍

给现有读者的说明 (A note for existing readers)

I’ve created a boilerplate / template project to help automate compiling, decompiling, packaging, etc… Link Here. And I tried my best to make it cross-platform and editor agnostic. If you’re about to start a new project and your interested in a template that lays out the groundwork for you then this would be that. Completely optional but there if your interested.

我创建了一个样板/模板项目,以帮助自动化编译,反编译,包装等..链接在这里。 我尽力使它跨平台且与编辑器无关。 如果您要开始一个新项目,并且对模板奠定了基础,而您对模板感兴趣,那么就是这样。 完全可选,但是如果您有兴趣的话。

In fact I wrote a whole tutorial on how to use it, link here

实际上,我写了一个完整的教程来介绍如何使用它,请点击这里

聚集词(Gathering Words)

I basically poked around the internet and gathered a large list of words that we’ll be using. Many forms of yes and no are local to your country and area so because I’m in America we’ll be pulling words from there.

我基本上是在互联网上闲逛,收集了大量我们将要使用的单词。 您可以在您所在的国家和地区使用多种形式的“是”和“否”,因此,因为我在美国,所以我们会从那里说一些话。

Normally though you’d want to have the list in a data file like JSON or XML and have many of them for different countries so that users can extend them themselves and all countries are included and the correct list is loaded based on the language of the player. — However that’s fairly complicated this early in the series so we’re going to shortcut and just pick a country and language. In the future, always keep in mind your audience. You never want to exclude people who may want to use your mod and in 2020 there are many established systems people have come up with related to localization to solve exactly that.

通常,尽管您希望将列表包含在JSON或XML之类的数据文件中,并且将其中的许多列表用于不同的国家/地区,以便用户可以自己扩展它们,并包括所有国家/地区,并根据播放器。 —但是,在本系列文章的开头部分,这是相当复杂的,因此我们将使用快捷方式,仅选择一个国家和语言。 将来,请始终牢记您的听众。 您永远不会排除可能想要使用您的mod的人,并且在2020年,人们已经提出了许多与本地化相关的成熟系统来解决这一问题。

Because the list is very large I’m going to place them in pastebin because I don’t want to fill up the articles with pages of words. You’re welcome to extend the list and add/or remove words.

因为列表很大,所以我将它们放置在pastebin中,因为我不想用单词页面填充文章。 欢迎您扩展列表并添加/或删除单词。

Link to the list of words.

链接到单词列表

添加到列表 (Adding to the list)

We import both the lists of true and false. Also be sure to copy the code here which contains all the words for both lists.

我们同时导入truefalse列表。 另外,请确保在此处复制包含两个列表的所有单词的代码

from sims4.commands import BOOL_TRUE, BOOL_FALSE

And then tell python to merge our lists into the official lists

然后告诉python将我们的列表合并到正式列表中

BOOL_TRUE.update(BOOL_TRUE_EXTRA)
BOOL_FALSE.update(BOOL_FALSE_EXTRA)

You’re code should look like this, many entries omitted to keep article size down.

您的代码应该看起来像这样,省略了许多条目以减小文章的大小。

from sims4.commands import BOOL_TRUE, BOOL_FALSEBOOL_TRUE_EXTRA = {
"yup",
"yea",
"yuppers",
...
"you-bet",
"mmhmm",
"way"
}BOOL_FALSE_EXTRA = {
"nope",
"nuh-uh",
":(",
...
"not-on-my-life",
"not-on-my-watch",
"no-way",
}BOOL_TRUE.update(BOOL_TRUE_EXTRA)
BOOL_FALSE.update(BOOL_FALSE_EXTRA)

你完成了 (You’re done)

That’s it, replacing code is great but extending lists, sets, dictionaries, etc… can open the door for many possibilities and the games code has many lists and such like this. Like I said though, adding to something is often safer then replacing something because 2 mods can both add to something but can’t both replace something. Neither is good or bad though because replacing and extending game code and data opens many doors of possibilities and can make for amazing mods.

就是这样,替换代码很棒,但是扩展列表,集合,字典等……可以为多种可能性打开大门,而游戏代码中也包含许多此类列表。 就像我说过的那样,添加某些东西通常比替换某些东西更安全,因为2个mod都可以添加到某些东西中,但不能同时替换某些东西。 不管是好是坏,因为替换和扩展游戏代码和数据打开了许多可能性之门,并且可以制作出惊人的mod。

Image for post

出版《模拟人生》 (Publication to Mod the Sims)

This has been accepted into Mod The Sims as a properly packaged mod. Link Here.

Mod Sims已将其作为正确打包的mod接受。 在这里链接

下一部分? (Next Part?)

Part 6 is available here.

第6部分在这里可用

翻译自: https://medium.com/@junebug12851/the-sims-4-modern-python-modding-part-5-extending-lists-fdc9dcb67980

sims算法

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值