- Joined
- Mar 9, 2016
- Messages
- 60
- Reaction score
- 10
- First Language
- English
- Primarily Uses
So, I am using and potentially adapting Bobstah's custom stat script to use for my game. Thank you Bobstah for all your hard work. I'm having trouble getting it to function how I want. I believe it will already do the first part of what I would like, but I am unable to get it to work. Here is the part of code that I am trying to figure out if I need to change.
Bobstah.CustomStats.defineStat = function(name, percent) {
var newObj = Bobstah.CustomStats.statList[name] = {
'name': name,
'percent': percent
};
if (typeof(Bobstah.CustomStats[name]) === "undefined") {
Bobstah.CustomStats[name] = newObj;
} else {
if (Bobstah.CustomStats[name].percent !== percent) {
console.warn("Conflicting percentage information for "+name+"!");
Bobstah.CustomStats[name].percent = true;
}
}
};
Bobstah.CustomStats.createStatNode = function(baseValue, op, evl, percent) {
if (op === "-") {
op = -1;
} else {
op = 1;
}
evl = evl || false;
percent = percent || false;
var obj = {
'baseValue': baseValue,
'eval': evl,
'modifiers': {},
'modifier': 0,
'percent': percent,
'op': op
};
return obj;
What I am gathering from this, is that it will not allow the first definition of a variable to be anything other than a whole number. I have a computation I want it to do, but I don't remember the function to get JavaScript to only value it as a whole number and not a humongous decimal. What I am wondering, is this only allowing for a whole number to be put in and cannot use an evaluation to determine the stat, such as str=$(a.level / 3 + 12).
Bobstah.CustomStats.defineStat = function(name, percent) {
var newObj = Bobstah.CustomStats.statList[name] = {
'name': name,
'percent': percent
};
if (typeof(Bobstah.CustomStats[name]) === "undefined") {
Bobstah.CustomStats[name] = newObj;
} else {
if (Bobstah.CustomStats[name].percent !== percent) {
console.warn("Conflicting percentage information for "+name+"!");
Bobstah.CustomStats[name].percent = true;
}
}
};
Bobstah.CustomStats.createStatNode = function(baseValue, op, evl, percent) {
if (op === "-") {
op = -1;
} else {
op = 1;
}
evl = evl || false;
percent = percent || false;
var obj = {
'baseValue': baseValue,
'eval': evl,
'modifiers': {},
'modifier': 0,
'percent': percent,
'op': op
};
return obj;
What I am gathering from this, is that it will not allow the first definition of a variable to be anything other than a whole number. I have a computation I want it to do, but I don't remember the function to get JavaScript to only value it as a whole number and not a humongous decimal. What I am wondering, is this only allowing for a whole number to be put in and cannot use an evaluation to determine the stat, such as str=$(a.level / 3 + 12).
Last edited by a moderator:
