Zozma

Veteran
Veteran
Joined
Dec 20, 2012
Messages
231
Reaction score
4
First Language
English
Primarily Uses
I'm trying to make a skill require a certain value in a variable in order to be usable. The idea is that the character's other skills increase the variable, and when that variable gets high enough the character can use their special skill. I'm using Yanfly's Skill Core (YEP) to attain this, but it doesn't seem to be working. The skill is usable regardless of the variable's value. Here's what I have in the skill's notetag:

<Custom Requirement>
if $gameVariables.value(102) = 3) {
value = true;
} else {
value = false;
}
</Custom Requirement>
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,986
Reaction score
2,343
First Language
Dutch
Primarily Uses
RMMV
you miss ( on start of

if ($gameVariables.value(102) == 3) {
//code
} else {
//code
}

I dont know is "value" is valid, as increasing this variable
require a different skill to increase it.

I dont know if its == 3 or === 3 or if it can be higher thant 3, use >= 3 instead.
but I dont know much lunatic code, so I cannot really help further.
 

Zozma

Veteran
Veteran
Joined
Dec 20, 2012
Messages
231
Reaction score
4
First Language
English
Primarily Uses
Works a treat. Thanks so much.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,943
Reaction score
3,143
First Language
English
Primarily Uses
RMMV
I dont know if its == 3 or === 3
For the purposes of RPG Maker you can always just use ==. Unless you're putting values into game variables yourself and using them to store strings or other non-numerical objects, there's no place in the code where strict equality will make a difference.
if $gameVariables.value(102) = 3) {
As ShadowDragon kind of pointed out, you have two syntax errors in here - you don't have the open parentheses, and you also are trying to set a return value of a function equal to 3, rather than checking to see if it is equal to 3.

As an additional tip, any time you are posting code you should use the CODE tags (the </> on the top bar).

So the correct syntax for what you're trying to do is:
Code:
<Custom Requirement>
if ($gameVariables.value(102)==3)
    value=true;
else
    value=false;
</Custom Requirement>

Or, to get rid of unnecessary lines,

Code:
<Custom Requirement>
value=$gameVariables.value(102)==3;
</Custom Requirement>
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,986
Reaction score
2,343
First Language
Dutch
Primarily Uses
RMMV
I didn't know you could do it with { and } for the if statement.
as lunatic seems to complex and how they are handles.

as JS is probably a slightly different to use in lunatic codes
for skills.

thanks for the additional explantion =)
 

Zeireth

Veteran
Veteran
Joined
Nov 2, 2013
Messages
81
Reaction score
64
First Language
English
Primarily Uses
N/A
I didn't know you could do it with { and } for the if statement.
as lunatic seems to complex and how they are handles.

as JS is probably a slightly different to use in lunatic codes
for skills.

thanks for the additional explantion =)
Yanfly's Lunatic Mode is literally just javascript for RPG Maker MV and MZ, and ruby script for RPG Maker VX and VX Ace.

Learn some javascript it might help your game. It only takes about 4 weeks to learn the basics. Resources to learn javascript is free if you look in the right places.

Countless free videos out there on Youtube plus free courses on code academy. When I started to learn I just typed javascript on search engine and started reading on w3 schools and whatever similar sites. Read intergers, strings, and variables first. Next read up on statements and operators such as if statements, loops, and switch statements. After that is arrays. Lastly functions.

If you can read up on each subject for a little bit each week, then you should be able to know basic skills for javascript.
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,943
Reaction score
3,143
First Language
English
Primarily Uses
RMMV
I didn't know you could do it with { and } for the if statement.
Do you mean without? I'm not sure what that means...I didn't type anything using braces in my example.
 

ShadowDragon

Realist
Veteran
Joined
Oct 8, 2018
Messages
5,986
Reaction score
2,343
First Language
Dutch
Primarily Uses
RMMV
<requirement>
if (code) {
//code
} else {
//code
}
</requirement>

this part where you use "code" without brackets or simple a 1 line,
unless it needs 2 different parts of effect.

@Zeireth I do know some JS, it's just difficult, and JS and lunatic
can have a small difference in the notetag by yanfly.

if you use that in a plugin, that code wont work at all.
 

Arthran

Veteran
Veteran
Joined
Jun 25, 2021
Messages
511
Reaction score
489
First Language
English
Primarily Uses
RMMZ
JS and lunatic
can have a small difference in the notetag by yanfly.
There is literally no difference between the JavaScript that you use in the note tag compared to regular JavaScript. The contents of the note tag are simply being run through JavaScript's eval function.
 

Zeireth

Veteran
Veteran
Joined
Nov 2, 2013
Messages
81
Reaction score
64
First Language
English
Primarily Uses
N/A
<requirement>
if (code) {
//code
} else {
//code
}
</requirement>

this part where you use "code" without brackets or simple a 1 line,
unless it needs 2 different parts of effect.

@Zeireth I do know some JS, it's just difficult, and JS and lunatic
can have a small difference in the notetag by yanfly.

if you use that in a plugin, that code wont work at all.
This is the first thing you learn about if statements. I do not know where you learned your if statements.

if (condition) {
// block of code to be executed if the condition is true
}

Else statement is the second thing you learn after if statements. There are 4 conditional statements; if, else, else if, and switch.

I do not mean any harm. I hope you can accomplish your goals. If you have time, please read up more about javascript.

I promise you that it will take some time to learn, the reward will be worth it. Just do not try to eat your elephant in one bite. Break it into bite size pieces and go from there. The only difficult parts are the advanced knowledge of javascript. It is true that mathematics are greatly need.

I would gauge basic knowledge of javascript requiring algebra, and advanced javascript requiring calculus. There are many things I need to learn. I am only a year into javascript.
 

Latest Threads

Latest Profile Posts

Regret that I wasn't able to actually finish my igmc entry in time for the actual igmc. Will probably just offload it as a standalone thing.
I'm a master in procrastination and have finally decided to educate people in this art in a seminar in Calais. Please don't come. I won't be there.
Testing some of my custom battlers (they're all trash, sorry).

a friend of mines said I need an elevator pitch for my game. he then went and gave me his for his comic... then I realized I have no idea how to explain my game the way he did his comic lol.

Forum statistics

Threads
124,422
Messages
1,163,461
Members
163,225
Latest member
onbetlive
Top