Triple linear condition Formula check

Nol

Veteran
Veteran
Joined
Oct 22, 2016
Messages
91
Reaction score
6
First Language
english
Primarily Uses
I'm using a skill to add different states depending on the actors level ; it'll be a very recuring type of skill, so i'll need to master the syntax.


I looked up some Ruby tutorials, and came up (100% self made, beware) with this :


if (a.level < 4) { a.addState(74); } else if (a.level < 7 and a.level > 3) { b.addState(74); } else if (a.level > 6) { b.addState(74); }


Somehow doen't work, sadly : /


also tried with "Elsif" but since nobody mentionned that here, i assumed it wasn't used


Could you give me a proper "stair like" version of this ? (the nice, much more readable thing, that people use in note boxes) ; it looks like for now, my only option is too leach and learn


What if i wanted to check for multiple conditions ?


Like "If actor is level 3,

  • If actor is at full health : gain X,
  • Else :  (not at full heatlh) : Heal,

if not level 3, do nothing"


Edit : I'd like to apologize for such simpl questions. I could look it up, and would eventually find out, but after an hour, i realized it would take me 50x the time for someone


fluent in ruby to answer it.


Looked for a "basic formulas repository for RMMV", but to no avail
 
Last edited by a moderator:

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Why are you looking at a Ruby tutorial if ur using MV? MV uses JavaScript not Ruby


Also, what do you mean by it doesn't work? Does all of those conditions doesn't work or just a few? 


This line of code (not taking into consideration if it works or not)

if (a.level < 4) { a.addState(74); } else if (a.level < 7 and a.level > 3) { b.addState(74); } else if (a.level > 6) { b.addState(74); }


can be simplified to


if (a.level < 4) { a.addState(74); } else if (a.level < 7) { b.addState(74); } else { b.addState(74); }


If the level of the user is < 4 it will execute the first block, now if it's not it will check the second block (meaning it will only check it if the first condition fails) so there's no point having the and a.level > 3 there, and the last else if can be just else since if the first two conditions are false, you can rest assured that the level is greater than 6.


now if it doesn't work then it could be that one or more of those calls is getting an error which on the case of the damage formula just makes it deal 0 damage so you can't troubleshoot it quickly. One good way to go is to check if .level and .addState actually exist.
 
Last edited by a moderator:

Nol

Veteran
Veteran
Joined
Oct 22, 2016
Messages
91
Reaction score
6
First Language
english
Primarily Uses
Lol, goddam it, i read somewhere about formula's being in ruby


Well...


Your formula worked perfectly, still don't know where i fudged mine, but now i have a template i can use, thanks.


Could you give me a similare template for a double If ?


As in this exemple :

"If actor is level 3,

  • If actor is at full health : gain X,
  • Else :  (not at full heatlh) : Heal,

if not level 3, do nothing"


The effects are purely for the sake of writing something, i'm just not sure how to write a second "If" without missing a }


Thanks for that quick answer
 

Engr. Adiktuzmiko

Chemical Engineer, Game Developer, Using BlinkBoy'
Veteran
Joined
May 15, 2012
Messages
14,682
Reaction score
3,003
First Language
Tagalog
Primarily Uses
RMVXA
Damage formula is in Ruby (RGSS3 actually not Ruby itself) if you're using VX Ace... for MV its on JavaScript


I also don't know why your's didn't work coz all I've done is remove the conditions that I felt are redundant.


for a double ifs.

Code:
if (conditon) {if (conditon) {actions}; else {actions};}; else {actions};
 
Last edited by a moderator:

Nol

Veteran
Veteran
Joined
Oct 22, 2016
Messages
91
Reaction score
6
First Language
english
Primarily Uses
Thanks for all those answers !


Have a nice making !


EDIT:


UGHHHHHH, why dosen't it work T.T


Here is my attempt at this multiple conditionnal code, arranged in a more readable state for the debugging, if you have a moment to point the semi colon likely missing...


I tried running only the last segment (if (p.Damage > 2)....) and it still returns the dreaded "0"


p.Damage works and is not the source of conflict

if (p.Damage > 8)


·         {if (b.isStateAffected(74)) {b.removeState(74) ; 18 };


·         else {b.addState(74); 9 };};


else


if (p.Damage > 6)


·         {if (b.isStateAffected(74)) {b.removeState(74) ; 14 };


·         else {b.addState(74); 7 };};


else


if (p.Damage > 4)


·         {if (b.isStateAffected(74)) {b.removeState(74) ; 10 };


·         else {b.addState(74); 5 };};


else


if (p.Damage > 2)


·         {if (b.isStateAffected(74)) {b.removeState(74) ; 6 };


·         else {b.addState(74); 3 };};


else


if (b.isStateAffected(74)) {b.removeState(74) ; 2 }; else {b.addState(74); 1 }
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??
Yay, now back in action Happy Christmas time, coming back!






Back in action to develop the indie game that has been long overdue... Final Fallacy. A game that keeps on giving! The development never ends as the developer thinks to be the smart cookie by coming back and beginning by saying... "Oh bother, this indie game has been long overdue..." How could one resist such? No-one c
So I was playing with filters and this looked interesting...

Versus the normal look...

Kind of gives a very different feel. :LZSexcite:

Forum statistics

Threads
105,854
Messages
1,017,004
Members
137,562
Latest member
tamedeathman
Top