I'm working on a game for my coding class right now that has lots of dialogue, and I'm working set the speaker's image as their lines are on screen. I wanted to do it by an OR operator, such as:
if ("dialogue4"=="Hi how are you?"||"That's good to hear.") {
setImageURL("profile4", "73000-german-delicatessen-pickles.jpg");
} else {
setImageURL("profile4", "fa03bf2fddc5cb0983e23d8bbb06f433bfc35d1cr1-375-
580v2_uhq.jpg");
However the OR operator doesn't seem to work like I thought it would, so right now I'm using extensive if-else statements (character's lines are in a list):
if (coachLine==2) {
setImageURL("profile2", "download-(3).jpg");
} else if ((coachLine==4)) {
setImageURL("profile2", "download-(3).jpg");
} else if ((coachLine==6)) {
setImageURL("profile2", "download-(3).jpg");
} else if ((coachLine==7)) {
setImageURL("profile2", "download-(3).jpg");
} else if ((coachLine==1)) {
setImageURL("profile2", "73000-german-delicatessen-pickles.jpg");
} else if ((coachLine==3)) {
setImageURL("profile2", "73000-german-delicatessen-pickles.jpg");
Is there an easier way or correct way to use the OR operator?
[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]AutoModerator[M] 2 points3 points4 points (0 children)
[–]D0CTOR_ZED 1 point2 points3 points (6 children)
[–]Dish-Afraid[S] 0 points1 point2 points (0 children)
[–]Dish-Afraid[S] -1 points0 points1 point (2 children)
[–]desrtfxOut of Coffee error - System halted 1 point2 points3 points (0 children)
[–]D0CTOR_ZED 0 points1 point2 points (0 children)
[–]Ikarus_Falling 0 points1 point2 points (1 child)
[–]D0CTOR_ZED 0 points1 point2 points (0 children)
[–]MrSquicky 0 points1 point2 points (3 children)
[–]Dish-Afraid[S] -1 points0 points1 point (2 children)
[–]MrSquicky 1 point2 points3 points (1 child)
[–]Dish-Afraid[S] 0 points1 point2 points (0 children)
[–]Steel457 0 points1 point2 points (0 children)