Tryna do a thing but, I suck


#1

Real quick just wanna figure out why this doesn’t work. I’m probably just stupid but that’s fine, I’m learning.

if (player.fullness >= player.maxFullness) {
msg (“Your too full to eat anymore.”)
player.maxFullness = player.maxFullness + GetRandomInt (5,35)
}
else if (player.fullness < player.maxFullness and HasString(this, “eatmsg”)) {
player.weight = player.weight + 0.08
msg (this.eatmsg)
player.fullness = player.fullness + 100
}
else {
msg (DynamicTemplate(“Eaten”, this))
}

It won’t add weight or fullness so.


#2

I assume this is JavaScript yes? And if so did you initialize fullness to something?

If there is more code I would include more of it.


#3

I’m really just starting so I really don’t know what I’m doing so, I’m gonna sound stupid. I’m like 99% sure this is javascript because it’s quest. I’m not sure what initializing fullness means but, I’m gonna guess it means just having the variable exist and it does, if that’s not what initializing is then I’m sorry. I’m also not sure if thats all the code I need to show so I’m stuck on that part. This is probably frustrating to work with me but I’m sorry and thanks for helping.


#4

I am not familiar with the Quest engine so I can be completely wrong here but assuming it is JavaScript if player.weight has a string in it (the “”) and not a number when you try to add to the weight or fullness (I am expecting the same issue) it will try to append a string instead of adding them together (for example: “1” + 1 = “11” instead of 1+1=2).

I would suggest to make sure weight and fullness are initially set to a number (also known as initialization).

When it comes to what code you should include when asking questions; usually more is better as important clues can be around the code that you are using. If able it is even better to attach the entire script if you can.


#5

I’m guessing that HasString(this, “eatmsg”) is returning false.
I would make sure you are giving eatmsg a value of some sort.

I also am unfamiliar with Quest. This is just a guess based on what you gave us.

If you see this msg then the if statement failed and your code to increase fullness and weight never ran.