Edgeklinge

Villager
Member
Joined
Oct 24, 2016
Messages
21
Reaction score
10
First Language
English
Primarily Uses
Right now, i'm using this

<On Creation Eval>
var skills = [3, 4, 5, 6]
var rdmId = skills[Math.floor(Math.random()*4)]
var trait = {code: 43, dataId: rdmId, value: 1}
item.traits.push(trait)
</On Creation Eval>

When the armor gets created, it'll pick a skill from 3,4,5,6 pool and assign it as an "add skill". But It is hard to deal with the description now since you'll never know which skill will be assign on that equipment.
So I want the description to show the skill name that is added when created.

I guess I should be using the same yanfly item core's <Info Eval> note tag, store the "skill that is assigned on the armor" as a variable and call it on description as for eg. "this armor adds /V[1] to the wearer"?
But I'm a noob at writing javascript myself, any help would be very appreciated :kaoswt:
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,039
Reaction score
2,463
First Language
English
Primarily Uses
RMMV
For the item's info field, put \V[X]

Then the notetag:

Code:
<Info Eval>
var skill=this.traits.filter(trait, trait.code==43);

if (skill.length>0)
    $gameVariables._data[X]="This longsword has been imbued with " + $dataSkills[skill[0].dataId].name;
else
    $gameVariables._data[X]="A longsword";
</Info Eval>

where X is the ID of a variable that isn't being used for anything else.
 

Edgeklinge

Villager
Member
Joined
Oct 24, 2016
Messages
21
Reaction score
10
First Language
English
Primarily Uses
For the item's info field, put \V[X]

Then the notetag:

Code:
<Info Eval>
var skill=this.traits.filter(trait, trait.code==43);

if (skill.length>0)
    $gameVariables._data[X]="This longsword has been imbued with " + $dataSkills[skill[0].dataId].name;
else
    $gameVariables._data[X]="A longsword";
</Info Eval>

where X is the ID of a variable that isn't being used for anything else.
For some reason, it just keep showing the number "0" on any info box. Is there anything I'm likely to miss before doing this?

Edited: so I tried to do some big brain stuff by just adding these

Code:
if (trait = 3)
    $gameVariables._data[1] = "Double Attack"
else if (trait = 4)
    $gameVariables._data[1] = "Wild Swing"
else if (trait = 5)
    $gameVariables._data[1] = "Triple Attack"
else
    $gameVariables._data[1] = "Sneak"

to the above code and the added skill name is finally showing on info box. BUT the problem is THEY ARE ALL THE SAME! So i guess it's because items being independent and they all using the same one variable? Is there any other way to work around this? lmao
 
Last edited:

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,039
Reaction score
2,463
First Language
English
Primarily Uses
RMMV
I tried to do some big brain stuff by just adding these to the above code and the added skill name is finally showing on info box. BUT the problem is THEY ARE ALL THE SAME! So i guess it's because items being independent and they all using the same one variable?
Well...no, it's because the stuff you added is not correct JavaScript code. You're taking a variable called trait (where did you declare it? What is it initialized to?) and then setting it equal to 3. So all of that code is pointless, because the first conditional will always make it be 3.

If you need help with something working, go back to what I originally gave you and post a screenshot of your item with the notetags. When you don't correctly know what you're doing with computer code, it never makes sense to guess.
 

Edgeklinge

Villager
Member
Joined
Oct 24, 2016
Messages
21
Reaction score
10
First Language
English
Primarily Uses
You're taking a variable called trait (where did you declare it? What is it initialized to?)
It is declared as an added skill in above <On Creation Eval> codes tho, at least that's how i thought lol xD I also tried with skill and rdmId but they were all the same but nvm now
If you need help with something working, go back to what I originally gave you and post a screenshot of your item with the notetags. When you don't correctly know what you're doing with computer code, it never makes sense to guess.
Screenshot_5.png

Screenshot_4.png
This is what happened tho. It's only showing 0 :kaocry:
 

ATT_Turan

Forewarner of the Black Wind
Veteran
Joined
Jul 2, 2014
Messages
4,039
Reaction score
2,463
First Language
English
Primarily Uses
RMMV
It is declared as an added skill in above <On Creation Eval> codes tho, at least that's how i thought...I also tried with skill and rdmId
Yeah, all of those are temporary variables declared inside of the code for that notetag. They're not somehow permanently stored on the item.
This is what happened tho. It's only showing 0 :kaocry:
That's weird...because even if the code in the Info Eval weren't working as expected, the portion in the else statement should give it that default description. There should be no circumstance where the game variable is left as 0.

If no one else has a thought, I'll try to troubleshoot a bit later this evening.

Edit: So I'm not sure why this isn't working. In the notetag I gave you, replace this with item and that part of the code will be correct...but the Info Eval still doesn't function like it should.

I can replicate in a new project that the eval isn't happening before the item info gets displayed - go ahead and check it. Look at the item, then scroll to a different one and go back, it should've changed.

But I'm not sure why...looking at the plugin code, in the item info refresh on line 1898 it's checking the eval before drawing the info text, and in the window intialization on line 1885 it's calling the refresh. So maybe I'm just really tired from the past few days, but I don't see why this isn't getting executed before the first time the text is displayed.

Maybe @caethyril or @Trihan can offer some insight.
 
Last edited:

Demonboy75

Skyrimdiddlyumptious
Member
Joined
Mar 5, 2018
Messages
5
Reaction score
4
First Language
English
Primarily Uses
RMMV
Sorry for necroposting, but I'm using this in a project that I'm making and I think I found a solution to the problem.

Code:
var skillList = item.traits.filter(trait => trait.code == 43);
var skillNames = skillList.map(x => ($dataSkills[x.dataId].name)).join(", ");
$gameVariables.setValue(1, skillNames);

(Edit. Originally, I poorly described this code even though I know in my head what it actually does, so I've updated my description): This creates an array which contains all Add Skill traits, creates a map which extracts the name of each skill added from each of these trait objects, joins that map together as a single string, and sets Game Variable 1 to that string, where it can be pasted to the item's Info Window via Yanfly's Item Core (the plugin being used to make this all possible). Since that text can be reevaluated every time the item is viewed, Game Variable 1 does not need to remain static.

I was greatly helped by your knowledge, so I hope I helped you too!
 
Last edited:

Latest Threads

Latest Posts

Latest Profile Posts

Maybe I should get rid of the Banish ability in my game. It's a non-elemental spell that doesn't even appear in the magic chart. It's only there because my Elementalist doesn't use light or dark magic. It only effects summoned creatures.
ScreenShot_5_18_2022_0_37_0.png
I've been redoing all of the major areas in my game. starting with a place called Century Park. thankfully because all of the locations are distorted memories, I can make these places pretty abstract.
HexMozart88 wrote on RHachicho's profile.
Hey wait a minute, I remember you!

Forum statistics

Threads
121,909
Messages
1,145,090
Members
160,171
Latest member
mutou000
Top