Senior Member
Join Date: Jan 2011
Location: Quebec, QC, Canada
Posts: 477
|
I am running into trouble with a particular item I am coding
It is a special armor that is easily enchanted with specific armor item powers, reducing the cost of such powers by half. I have tried the following 2 scripts at First - 2550, but I get the error message: Syntax error in 'eval' script for Thing 'mAMSAWvScl' (Eval Script '#1') on line 1 -> Script reference is invalid under the circumstances Code:
perform findchild[BaseItemPw,thingid.ipAMSAArFo?].setfocus focus.field[iPriceCash].value *= 0.5 Code:
perform container.gizmo.setfocus if (focus.tagis[thingid.ipAMSAArFo?] <> 0) then focus.field[iPriceCash].value *= 0.5 endif Code:
foreach pick in gizmo from BaseItemPw where "thingid.ipAMSAArFo?" eachpick.field[iPriceCash].value *= 0.5 nexteach Attempt to access non-existent containing entity from script - - - Can't foreach over invalid container (this is probably related to a previous error) - - - Can't foreach over invalid container (this is probably related to a previous error) Finally, it dawned on me that the armor type and the item powers are both gizmos on a magic armor pick, so I tried Code:
perform container.parent.setfocus perform focus.findchild[BaseItemPw,thingid.ipAMSAArFo?].setfocus focus.field[iPriceCash].value *= 0.5 Is it possible to steer me in the right direction or at least to point me to an item that does a similar thing? I feel like I'm getting lost in transitions here. Thanks! |
#1 |
Senior Member
Join Date: Jul 2010
Posts: 3,151
|
Am I to understand you want a set of armor to reduce the cost of things you add to it? In general, scripts can only affect things that are on the character already, so until you purchase the thing, you can't reduce the cost (AFAIK). That said, the error on your first script is likely due to missing quotes:
Code:
perform findchild[BaseItemPw,"thingid.ipAMSAArFo?"].setfocus [thingid.?] = OK [thingis.ipAM?] != OK Also, when using setfocus, it's good practice to include the following line after: Code:
doneif (state.isfocus = 0) Last edited by Sendric; August 13th, 2023 at 07:37 AM. |
#2 |
Senior Member
Join Date: Jan 2011
Location: Quebec, QC, Canada
Posts: 477
|
Quote:
I have been able to manipulate the cost of an added weapon power in another instance; the script was on the power itself and referred to the weapon type. I may have to re-visit that again; I just had to establish focus on the parent container for that one (iMagWeapon or something like that), strangely enough, and not on the weapon gizmo itself. Quote:
Quote:
Indeed. I have not been used to this, it's the first time I delve into parent and gizmo stuff. Will do! Thanks! |
|||
#3 |
Senior Member
Join Date: Jan 2011
Location: Quebec, QC, Canada
Posts: 477
|
Quote:
Quote:
Among my script attempts, the only two that compile without spitting out a syntax error are: Code:
~ First - 2550 (altering iPriceCash must be done early) foreach pick in gizmo from BaseItemPw where "thingid.ipAMSAArFo?" eachpick.field[iPriceCash].value *= 0.5 nexteach Attempt to access non-existent containing entity from script - - - Can't foreach over invalid container (this is probably related to a previous error) - - - Can't foreach over invalid container (this is probably related to a previous error) Code:
~ First - 2550 perform gizmo.findchild[BaseItemPw,"thingid.ipAMSAArFo?"].setfocus focus.field[iPriceCash].value *= 0.5 Attempt to access non-existent containing entity from script - - - Attempt to access 'focus' pick or thing from script when no focus exists - - - Attempt to access 'focus' pick or thing from script when no focus exists At least in the second case, I get that it does not "find" a suitable target pick. And that is where I am stuck at the moment. I have read that you can only foreach on hero and gizmo, not parent or other containers, and attempts at these indeed ended up in errors. If anybody has other pointers (or can just confirm that what I am aiming for in fact cannot be done), I'll gladly take them. Thanks again! Last edited by Lord Magus; August 14th, 2023 at 06:32 PM. |
||
#4 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,243
|
I just want to check a basic setting - you're sure you set up this new magic armor to have a gizmo?
At the bottom of the thing definition of the armor itself should be a child entry, like this: <child entity="mSpecMagic"> <bootstrap thing="arBanded"/> </child> </thing> Or if you're viewing this in the editor, the Gizmo button is among the grid of blue buttons on the right-hand side. If you created the item on the Armor, Magic tab, it'll default to having a gizmo, but the error messages you're receiving suggest it doesn't have one. |
#5 |
Senior Member
Join Date: Jan 2011
Location: Quebec, QC, Canada
Posts: 477
|
Quote:
When this non-magical armor is used to create a custom magic armor (on the Armor tab of a character) (i.e. when it is added as a gizmo to the iMagArmor pick), it reduces the cost of certain armor item powers that can be added along to it to iMagArmor. So it's the non-magical armor I'm creating, not a specific magic armor on the Magic armor tab of the editor. When the base version of the armor is used, it's just a fine masterwork set of scale mail. |
|
#6 |
Senior Member
Join Date: Jan 2011
Location: Quebec, QC, Canada
Posts: 477
|
See attached pics to clarify...
|
#7 |
Senior Member
Lone Wolf Staff
Join Date: May 2005
Posts: 13,243
|
At this point, I recommend posting the entire thing element for this armor, copied from the .user file you've created - open that file in a text editor, and find the definition of this armor, and copy it and paste it here. As an example of what you're looking for, this is plain old studded leather:
Code:
<thing id="arStudded" name="Studded leather"description="An improved form of leather armor, studded leather armor is covered with dozens of metal protuberances. While these rounded studs offer little defense individually, in the numbers they are arrayed in upon such armor, they help catch lethal edges and channel them away from vital spots. The rigidity caused by the additional metal does, however, result in less mobility than is afforded by a suit of normal leather armor." compset="Armor"> <fieldval field="gWeight" value="20"/> <fieldval field="gSizeCost" value="25"/> <tag group="ArmorAC" tag="3"/> <tag group="ArmorMaxDx" tag="5"/> <tag group="ArmorCheck" tag="1"/> <tag group="ArmorArcFl" tag="15"/> <tag group="ArmorClass" tag="Light"/> <tag group="EquipType" tag="MetalSome"/> <tag group="EquipType" Leather"/> </thing> |
#8 |
Senior Member
Join Date: Jul 2010
Posts: 3,151
|
You may need to put an if statement in to prevent this from running until it's magical.
|
#9 |
Senior Member
Join Date: Jan 2011
Location: Quebec, QC, Canada
Posts: 477
|
|
#10 |
|
|