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
6,044
Reaction score
2,367
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
5,055
Reaction score
3,211
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
6,044
Reaction score
2,367
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
5,055
Reaction score
3,211
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
6,044
Reaction score
2,367
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
516
Reaction score
498
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 Posts

Latest Profile Posts

I may or may not be slightly crazy. Since I couldn’t find anything to renumber generator parts files that works on Linux, I’m scripting something up to run via terminal that’ll do the job. (Face is done (and was a fustercluck-and-a-half), and I’m taking a well-earned break before tackling SV, TV, TVD, and Variation. @.@)
I fixed my little itch.io issue... apparently filenames are case-sensitive. After I renamed the file IconSet.png instead of Iconset.png, it worked. I changed it back and forth a few times just to confirm this.

I'm gonna go beat my head against the wall now.

and an original idea of people having alter egos is back... finally.
Another camping area.
I just found out somebody pirated my 3,99$ game. I spent over a year making it and somebody just publish it for free a week after early access released.

I should be glad, cuz if they pirate you, that means your game has to be good, but im not. I barely sold any copy. Didn't get any info from most of the sites I wrote.

Forum statistics

Threads
124,642
Messages
1,164,926
Members
163,466
Latest member
nnl94
Top