View Single Post
Sendric
Senior Member
 
Join Date: Jul 2010
Posts: 3,147

Old December 14th, 2020, 05:25 AM
Quote:
Originally Posted by draco963 View Post
Ok I'll try to be clearer about the field[value] thing.

But, my concern was that the command to increase the SneakAttack value is nested under an If statement, which checks that Rit value assigned above.

As you can see, in that long chunk above, there are two entirely separate things, The Ritual count and the Sneak Attack dice count, both referenced as "field[Value].value", which in my brain, breaks.

So, I finally tested it just now , and it does appear to work. But I truly do not understand why...
So as you have already learned, this is totally fine. Why? Because:

Code:
Rit = field[Value].value
means "set the variable Rit equal to the value of the Value field on the thing this script is written in"

while

Code:
hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 1
means "add 1 to the value of the Value field of the thing xSneakAtt".

In each case you are referencing the Value field, but of two different things. If you don't include "hero.child[xxx]." before "field[Value].value" it defaults to the thing the script is written on.

Two coding tips to be aware of:

1) It's often better to use "hero.childfound" instead of "hero.child". Adding found reduces the potential for error messages because it will only function if the the thing you're trying to manipulate is found on the hero. "hero.child" should only be used in cases where you know for sure the thing will always be on the hero in all situations.

2) The following two lines of code mean exactly the same thing:

Code:
hero.child[xSneakAtt].field[Value].value = hero.child[xSneakAtt].field[Value].value + 1
Code:
hero.child[xSneakAtt].field[Value].value += 1
For obvious reasons, I generally prefer the one with less characters.

Quote:
Originally Posted by draco963 View Post
As for the ShowMenu drop-down list for Legacy Wondrous items:
I'm confused how/why this script is working also. In the Editor, the actual ShowMenu selection for the Wondrous Items Legacy Adjustment is currently set to "Current Armor". When I use the script you sent me, it nevertheless shows only the Magic Items on the Hero. I changed it to check BaseWonder instead, and now it shows only Assassin's Hands. This is great! Fantastic, wunderbar! But, is there any way to add a different entry to the ShowMenu list itself? I think I understand what the script is doing (replacing the selected drop-down list with the scripted one), but if I add a new tag to the ShowMenu drop-down in the Editor, the script breaks, and shows me every wondrous item, instead of those only on my hero. How can I build a new ShowMenu slection?

Thank you Sendric! I really appreciate the help and your explanations!
The script works because of the timing. The ShowMenu selection sets the field at Pre-Levels/10000. Unfortunately, this seems to not be working properly. I can't do much about that, so instead we create a script to replace the field with what we want immediately after that time. This is perfectly fine and easier than trying to deal with creating a new tag.

As to why adding a new tag breaks it, I'm not sure, but I'd recommend sticking with using a script to set it. You still need to use a tag to make sure the show selection drop down appears in the adjustment, but you should use one of the pre-set ones and not a new one.

You originally asked for a script that showed all magic items, which is what I provided. Are you looking for something narrower?
Sendric is offline   #12 Reply With Quote