Hello everybody,
this is my first post in the forum and I'm new to Twine, so.. hi I'm Alessio and I'm from Rome sorry for my bad english in advance :P
I started building my very first game yesterday, downloaded sugarcube 2 and started to code my story.
I have an overall advanced knowledge of HTML and Javascript, so I tried to build a game with an heavy background logic. I looked at the sucarcube 2 wiki but I couldn't find anything that could help me.
So my problem his, characters in my game have stats, let's say I have those 3
<<set $jake to {
character : {
name : "Jake",
stats : {
power : 0,
look: 0,
intelligence: 0
},
....
}>>
now my dear Jake is wearing a jacket that gives him a +5 at the look stats, but also holds other items that he currently doesn't have equipped so my code is something like
<<set $jake.inventory to {
items: [ ... ],
gold: 150,
wear: [
{
name : "leather jacket",
isOn: true,
mods: {look:5},
description: "...."
},
{
name: "winter coat",
isOn: false,
mods: {look:1, coldResist:10}
}
],
....
}>>
now in the stats menu tab I want to show all his stats added with all the wearable items he currently has on (in this case just a +5 to look given by leather jacket
so after grabbing the mods object from all the objects in wear array with isOn set to true I'd like to cycle all the stats in there
Assuming for simplicity that I can have only an item with isOn set to true I can grab the mods object and store it in a
_wearMods object
then I'd like to cycle over it with a (for in) like this:
<<for _key in _wearMods>>
<<set _stats[_key]+=_wearMods[_key]>>
<</for>>
in this way I could add more stats later on in the game without having to rewrite all my code
that for just seems not to work, no error or such, but it doesn't work so i sticked to an if for all the stats i currently have planned
Probably I haven't been clear, tell me if something doesn't sound you,
thanks in advance!
K.
this is my first post in the forum and I'm new to Twine, so.. hi I'm Alessio and I'm from Rome sorry for my bad english in advance :P
I started building my very first game yesterday, downloaded sugarcube 2 and started to code my story.
I have an overall advanced knowledge of HTML and Javascript, so I tried to build a game with an heavy background logic. I looked at the sucarcube 2 wiki but I couldn't find anything that could help me.
So my problem his, characters in my game have stats, let's say I have those 3
<<set $jake to {
character : {
name : "Jake",
stats : {
power : 0,
look: 0,
intelligence: 0
},
....
}>>
now my dear Jake is wearing a jacket that gives him a +5 at the look stats, but also holds other items that he currently doesn't have equipped so my code is something like
<<set $jake.inventory to {
items: [ ... ],
gold: 150,
wear: [
{
name : "leather jacket",
isOn: true,
mods: {look:5},
description: "...."
},
{
name: "winter coat",
isOn: false,
mods: {look:1, coldResist:10}
}
],
....
}>>
now in the stats menu tab I want to show all his stats added with all the wearable items he currently has on (in this case just a +5 to look given by leather jacket
so after grabbing the mods object from all the objects in wear array with isOn set to true I'd like to cycle all the stats in there
Assuming for simplicity that I can have only an item with isOn set to true I can grab the mods object and store it in a
_wearMods object
then I'd like to cycle over it with a (for in) like this:
<<for _key in _wearMods>>
<<set _stats[_key]+=_wearMods[_key]>>
<</for>>
in this way I could add more stats later on in the game without having to rewrite all my code
that for just seems not to work, no error or such, but it doesn't work so i sticked to an if for all the stats i currently have planned
Probably I haven't been clear, tell me if something doesn't sound you,
thanks in advance!
K.