mirror of
https://github.com/Acamaeda/The-Modding-Tree.git
synced 2025-01-18 19:51:30 +00:00
Improved toValue
This commit is contained in:
parent
d28e64fd66
commit
6cbe548084
4 changed files with 14 additions and 7 deletions
|
@ -8,12 +8,14 @@
|
|||
- Upgrade effectDisplay and grid tooltip no longer display if they return "".
|
||||
- devSpeed can be 0.
|
||||
|
||||
- Fixed an issue with text-input not converting types correctly.
|
||||
- Text-input now goes back to the old value if an invalid value is entered.
|
||||
|
||||
|
||||
# v2.6.6.2 = 9/9/21
|
||||
# v2.6.6.2 - 9/9/21
|
||||
- nodeStyle can now be used to set fonts.
|
||||
|
||||
# v2.6.6.1 = 9/8/21
|
||||
# v2.6.6.1 - 9/8/21
|
||||
- Fixed options not updating when new ones are added.
|
||||
|
||||
# v2.6.6 - 9/7/21
|
||||
|
|
|
@ -45,7 +45,7 @@ These are the existing components, but you can create more in [components.js](/j
|
|||
|
||||
- prestige-button: The button to reset for a currency in this layer.
|
||||
|
||||
- text-input: A text input box. The argument is the name of the variable in player[layer] that the input is for, player[layer][argument]
|
||||
- text-input: A text input box. The argument is the name of the variable in startData/player[layer] that the input is for, player[layer][argument]
|
||||
(Works with strings, numbers, and Decimals!)
|
||||
|
||||
- slider: Lets the user input a value with a slider. The argument a 3-element array: [name, min, max].
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
let gameInfo = {
|
||||
name: "The ??? Tree",
|
||||
name: "The ??? Game",
|
||||
id: "mygame",
|
||||
author: "nobody",
|
||||
pointsName: "points",
|
||||
|
|
11
js/utils.js
11
js/utils.js
|
@ -345,15 +345,20 @@ function isPlainObject(obj) {
|
|||
|
||||
document.title = gameInfo.name
|
||||
|
||||
// Converts a string value to whatever it's supposed to be
|
||||
// Converts an input value to whatever it's supposed to be
|
||||
function toValue(value, oldValue) {
|
||||
if (oldValue instanceof Decimal) {
|
||||
value = new Decimal (value)
|
||||
if (checkDecimalNaN(value)) return decimalZero
|
||||
if (checkDecimalNaN(value)) return oldValue
|
||||
return value
|
||||
}
|
||||
if (typeof oldValue === 'string' ) {
|
||||
value = value.toString()
|
||||
return value
|
||||
}
|
||||
if (!isNaN(oldValue))
|
||||
return parseFloat(value) || 0
|
||||
value = parseFloat(value)
|
||||
if (isNaN(value)) return oldValue
|
||||
return value
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue