Modding:Basic Modding Examples: Difference between revisions

From Vintage Story Wiki
Updates bed example to current version
(Microblock chiseling is no longer controlled from the chisel)
(Updates bed example to current version)
Line 17: Line 17:
== Changing sleep duration in beds ==
== Changing sleep duration in beds ==


Beds in the Vanilla game are pretty limited, as they let you only sleep 3-5.5 hours every night. More often than not players prefer to skip the whole night. To achieve that open the file <code>assets/blocktypes/wood/generic/bed.json</code>
Beds in the Vanilla game are pretty limited, as they let you only sleep 3-5.5 hours every night. More often than not players prefer to skip the whole night. To achieve that open the file <code>assets/survival/blocktypes/wood/bed.json</code>


Line 7-11 should contain these lines:
Line 8-11 should contain these lines:
<syntaxhighlight lang="json">
<syntaxhighlight lang="json">
attributesByType: {
sleepEfficiencyByType: {
"bed-wood-*": { sleepEfficiency: 0.375 },
"bed-wood-*": 0.70833333,
"bed-hay-*": { sleepEfficiency: 0.25  },
"bed-hay-*": 0.58333333,
"bed-woodaged-*": { sleepEfficiency: 0.45833  }
"bed-woodaged-*": 0.79166666
},
},
</syntaxhighlight>
</syntaxhighlight>


The <code>sleepEfficiency</code> attribute is specific to the bed. In this case a value of 1 means the player can sleep half the day. The hay bed has a value of 0.25, which means the player can sleep for 12 * 0.25 = 3 in-game hours. Change the value to anything between 0...1 and start the game or leave and re-enter your singleplayer world. Next time you sleep in the bed you will be skipping that amount of time.
The <code>sleepEfficiency</code> attribute is specific to the bed. In this case a value of 1 means the player can sleep half the day. The hay bed has a value of 0.58333333, which means the player can sleep for 12 * 0.58333333 = ~7 in-game hours. Change the value to anything between 0...1 and start the game or leave and re-enter your singleplayer world. Next time you sleep in the bed you will be skipping that amount of time.




editor
72

edits