Starting player's inventory

This commit is contained in:
bgiraudr 2022-04-16 02:21:07 +02:00
parent 3c15b5d4a5
commit 3d3361151b
6 changed files with 32 additions and 2 deletions

View File

@ -15,6 +15,9 @@ def convert(input, output, params, target):
elif params["custom-type"] == "player_moves":
convert_player_moves(input, output, params, target)
return 0
elif params["custom-type"] == "items":
convert_items(input, output, params, target)
return 0
else:
return 1
@ -294,4 +297,20 @@ def convert_player_moves(input, output, params, target):
levelup += fxconv.u32(int(i.split(":")[1]))
levelupplayer += fxconv.ptr(levelup)
fxconv.elf(levelupplayer, output, "_" + params["name"], **target)
fxconv.elf(levelupplayer, output, "_" + params["name"], **target)
def convert_items(input, output, params, target):
liste_file = list(pathlib.Path(input).parent.glob('*.json'))
items = fxconv.Structure()
items += fxconv.u32(len(liste_file))
for f in liste_file:
file = open(f,"r")
data = json.load(file)
item = fxconv.Structure()
item += fxconv.string(data["name"])
item += fxconv.u32(data["id"])
items += fxconv.ptr(item)
fxconv.elf(items, output, "_" + params["name"], **target)

4
assets-cg/items/1.json Normal file
View File

@ -0,0 +1,4 @@
{
"name":"Test1",
"id":1
}

4
assets-cg/items/2.json Normal file
View File

@ -0,0 +1,4 @@
{
"name":"Obj2",
"id":2
}

View File

@ -0,0 +1,3 @@
items.txt:
custom-type: items
name: items

View File

View File

@ -182,7 +182,7 @@
<object id="61" gid="267" x="464" y="432" width="16" height="16">
<properties>
<property name="name" value="Pancarte"/>
<property name="text" value="De quoi bien commencer l'aventure !;~xp:500;De rien :)"/>
<property name="text" value="De quoi bien commencer l'aventure !;~move:3;De rien :)"/>
</properties>
</object>
</objectgroup>