If then else statements, where to get skill information? - SOLVED

You can just write item in the damage formula box to refer to the active skill.


I think at this point it might be easier to construct a Game_Action and call evalDamageFormula on it. That'll automatically get you a and b, and it'll also get item and v and anything else a plugin might add. Of course, this is assuming that you have all the pieces you need, which might not be the case when you're writing code in the description box...

So I'm afraid there's probably no way to actually use the same line for every skill using just evalText (unless Yanfly has some sort of special case for using it in an item description).

You can definitely write it in such a way to allow you to copy-paste and change just a single constant for each skill, though. If that's not good enough you'll probably need a plugin that somehow makes the information available in the help window.

Or actually, come to think of it, if "this" refers to the help window then there might actually be a way...
evalText didn't really work well but WAY_EvalText works a lot better for it.

But something I was considering was wheter or not it would be possible to have the description apply itself to every skill description, therefore any and all changes to the description will be applied to every skill without any need for copy paste at all.

I know it is possible somehow, I was contemplating trying to set a variable to the general description text and then just write one line of code in the actual skill description which would be the string variable containing the description.

But I don't understand how the code will be called in that situation. Firstly the "" will need to go away so that it reads the code of the variable rather than the actual string. Then it will also need to properly apply the code to the current skill which we already touched upon. It will also need to call the correct a variable for the formulas and similar.

I don't know if it is possible but if it is that would be neat.


I'll keep trying stuff and hopefully you guys that understand it more might have a strike of genius and solve all of it 🙂
1596364391772.png


How do I get the value 54 from the array and how do I get the value of 0.2 from the array as a single value usable in comparisons and math functions?

EDIT: hehe
1596364542167.png
If you do

Code:
var aryStates = $dataSkills[1113].effects.filter(effect => effect.code === 21).map(effect => [effect.dataId, effect.value1])

You can then use aryStates[index][0] for the code and aryStates[index][1] for the value.
If you do

Code:
var aryStates = $dataSkills[1113].effects.filter(effect => effect.code === 21).map(effect => [effect.dataId, effect.value1])

You can then use aryStates[index][0] for the code and aryStates[index][1] for the value.
Thank you Trihan!
($dataSkills[1113].effects.filter(effect => effect.code === 21).map(effect => [effect.dataId]) ? $gameVariables.value(261) : "")

I am wondering if there is any way to make the above code include more return values if the statement is true. Been looking a bit on google but haven't found anything.

I've tried below with no luck.
($dataSkills[1113].effects.filter(effect => effect.code === 21).map(effect => [effect.dataId]) ? $gameVariables.value(261) & eval(Math.floor($gameVariables.value(262))) & $gameVariables.value(263) : "")
Is there any way to do the following without returning "undefined"?
1596404813953.png

It shows up in the description...
1596404833099.png
Use + instead of &. Though the whole point of map is to use the array element somehow in the return. If you're not using the effect, why not just return the concatenated variables outright? Also your ternary if statement is always going to return true because you can't have an effect that doesn't have a dataId.
Use + instead of &. Though the whole point of map is to use the array element somehow in the return. If you're not using the effect, why not just return the concatenated variables outright? Also your ternary if statement is always going to return true because you can't have an effect that doesn't have a dataId.
Ah yes, I noted the issue with the if statement. I changed it to below.
//if stateID = 54(burn) then write string1 + value(damage) + string2

(Math.floor($dataSkills[1113].effects.filter(effect => effect.code === 21).map(effect => [effect.dataId])) === 54) ? $gameVariables.value(261) + Math.floor(eval($gameVariables.value(262))) + $gameVariables.value(263) : "";

--> "inflict burn that does 360 fire damage per turn"

So far haven't tested a false statement, but I did notice before that I never actually compared the value so I added the "===54" and I believe that is what you saw as well 🙂

And I don't really get what you mean how I would use it more effectively, there almost certainly are ways to do it more effectively but also the chance and the description will be in separate places I believe.
The absence of the === 54 is what was throwing me off, yeah.
(unless Yanfly has some sort of special case for us
Is there any way to do the following without returning "undefined"?
View attachment 153825
It shows up in the description...
View attachment 153826

As you seemed aware of this I focus this question to you so you will notice the question 🙂

Extension to the question would be the code I am trying to use here. It's shortened to 2 if statements just to test the function.
Code:
$gameVariables.setValue(251, 1113);
($dataSkills[$gameVariables.value(251)].damage.type === 1) ? "deals" : "";
($dataSkills[$gameVariables.value(251)].damage.type === 3) ? "heals" : "";

And as the image shows the statement returns one true and one false value showing that setting the variable 251 to the value of the currently selected skill description returns the correlating skill. If this works and I can remove the "undefined" that is returned from setting the variable then I just need to change one tiny parameter for every copy paste, otherwise I have to set every single if-statement to the value I am after.

---

Another thing that I thought of is if there wouldn't be anyway to check which skillID the player is currently selected or hovering?
1596406429193.png

In this case Fire Bolt which has the 1113 ID.
So if you could access the ID like that somehow with a script like $dataCursor.selection.baseItem.skillID(), and that script is just imaginary and used to explain kinda what I mean, then it would work. The important thing is not to actually refer to the skill, the important part is to make it so that I can get the ID-number of the skill rather than the actual skill. So anyway that would give me the value 1113 without ever having to write 1113 and will also be applicable to all the skills XXXX would be so perfect.

Best regards,
Bishiba
The absence of the === 54 is what was throwing me off, yeah.
Also added the Math.floor to make sure it's a value and not an integer 🙂
If you do

Code:
var aryStates = $dataSkills[1113].effects.filter(effect => effect.code === 21).map(effect => [effect.dataId, effect.value1])

You can then use aryStates[index][0] for the code and aryStates[index][1] for the value.
Wouldn't it be easier to drop the map in that case?

JavaScript:
var aryStates = $dataSkills[1113].effects.filter(effect => effect.code === 21)
// Then use this for the code...
aryStates.dataId
// ...and this for the value
aryStates.value1
Try

Code:
var window = SceneManager._scene instanceof Scene_Skill ? SceneManager._scene._itemWindow : SceneManager._scene._skillWindow;
$dataSkills[window._data[window.index()].id]
Try

Code:
var window = SceneManager._scene instanceof Scene_Skill ? SceneManager._scene._itemWindow : SceneManager._scene._skillWindow;
$dataSkills[window._data[window.index()].id]
Below return value, I am certainly misunderstanding something.
1596458387269.png
If you're using plugins they may have changed the windows that are in the skill scene. Are you using Skill Core?
If you're using plugins they may have changed the windows that are in the skill scene. Are you using Skill Core?
I am yes, full plugin list below.
Plugin list.png
Oh, whoops. Window is already a global variable for the engine.

Code:
var listWindow = SceneManager._scene instanceof Scene_Skill ? SceneManager._scene._itemWindow : SceneManager._scene._skillWindow;
$dataSkills[listWindow._data[listWindow.index() !== -1 ? listWindow.index() : 0].id]
Oh, whoops. Window is already a global variable for the engine.

Code:
var listWindow = SceneManager._scene instanceof Scene_Skill ? SceneManager._scene._itemWindow : SceneManager._scene._skillWindow;
$dataSkills[listWindow._data[listWindow.index() !== -1 ? listWindow.index() : 0].id]
It returns the following values. How do I retrieve only the ID 1113?
1596462031176.png
$dataSkills[listWindow._data[listWindow.index() !== -1 ? listWindow.index() : 0].id].id

Though if all you want is the ID, you can just do

listWindow._data[listWindow.index() !== -1 ? listWindow.index() : 0].id
$dataSkills[listWindow._data[listWindow.index() !== -1 ? listWindow.index() : 0].id].id

Though if all you want is the ID, you can just do

listWindow._data[listWindow.index() !== -1 ? listWindow.index() : 0].id
Argh, was thinking "Should I try to add .id after, nah, can't be that easy."...

But it's good to know how to retrieve more information in case I need it.

Currently I need only the ID for if-statement. Does "-1" stand for current view or something?

Original thread: https://forums.rpgmakerweb.com/threads/if-then-else-statements-where-to-get-skill-information-solved.124804/