kbenigne学习3 get-started 2创建实体

https://www.comblockengine.com/docs/1.0/get-started/createentity/

2 从官网文档复制FirstEntity时,不要把...也给复制了

<root>
    <!--属性定义-->
    <Properties>
        <!--角色的名字-->
        <name>
            <!--unicode作为名字类型-->
            <Type>              UNICODE     </Type>
            ...#删掉
            ...#删掉
            <!--BASE上拥有该属性-->
            <Flags>             BASE        </Flags>
        </name>
    </Properties>
</root>

https://www.comblockengine.com/docs/1.0/get-started/createentity.py/

在 “scripts/base/kbemain.py,在onBaseAppReady函数下添加如下代码:”时,注意缩进。

kbe自带的assets文件中的base/kbemain.py里默认缩进是tab,而我的vscode设置成了pep8的4个空格(https://www.cnblogs.com/xuanmanstein/p/9181592.html

注意显示出区别,不要混用2种缩进,导致报错,baseapp的进程会退出,表现是9个控制台窗口剩8个。

此外,稍微进行修改:更pythonic一点 ^_^

1 删除开头的# -*- coding: utf-8 -*-   py3已经不需要这个了

2 在def __init__(self) 中,使用super()代替直接写一遍父类名字 KBEngine.Entity。

 

用控制台查看entity时,只√ baseapp, 不要把全部app都勾上,否则debug看不到entity,会返回空[]

注意查到的id可能不是官网文档的2 我这里是2001

原文地址:https://www.cnblogs.com/xuanmanstein/p/9178723.html