temnix Posted July 24, 2021 Share Posted July 24, 2021 (edited) I'm making an item that will let the character examine the inventory of another creature. Its items will be listed one by one in the bottom window. For this I wrote a starter script with some basic conditions and went on to go through all ITM files and add a piece to that file for each, taken from a template: IF Global("FIRST","LOCALS",1) Global("%item%","LOCALS",0) < - This resource name is filled in from the tp2 file HasItem("%item%",LastSummonerOf) < - The summoner of the invisible minion who runs this script, i.e. the target THEN RESPONSE #5 SetGlobal("%item%","LOCALS",1) < - To avoid displaying the line for this item a second time SetToken("ITEM-NAME",%name-string%) < - The unidentified name of the item, taken from the tp2 SmallWait(2) DisplayString(LastHeardBy,@652) < - The string with the <ITEM-NAME> token inside, shouts are used for targeting Continue() RESPONSE #1 < - Alternative strings for variety SetGlobal("%item%","LOCALS",1) SetToken("ITEM-NAME",%name-string%) SmallWait(2) DisplayString(LastHeardBy,@653) Continue() RESPONSE #1 SetGlobal("%item%","LOCALS",1) SetToken("ITEM-NAME",%name-string%) SmallWait(2) DisplayString(LastHeardBy,@654) Continue() RESPONSE #1 < - The chance to omit the info for this item, the observation device is not precise SetGlobal("%item%","LOCALS",1) Continue() END The problem is that the information should be shown in order, instead the info about the first (highest) item on the list that is found is skipped and the info about the last (lowest) item the target carries is doubled. The script that checks for this ends up with blocks for every one of thousands of items, and I thought that the length somehow goes to the engine's head. But when I wrote a shorter version of the script, just for the items Tiax has on him, this kept happening. Tiax in my game is carrying this equipment: And the script for him is: IF Global("FIRST","LOCALS",1) Global("BULL01","LOCALS",0) HasItem("BULL01",LastSummonerOf) // Bullet THEN RESPONSE #5 SetGlobal("BULL01","LOCALS",1) SetToken("ITEM-NAME",6633) // Bullet SmallWait(3) DisplayString(LastHeardBy,40011) // <ITEM-NAME>... Continue() RESPONSE #1 SetGlobal("BULL01","LOCALS",1) SetToken("ITEM-NAME",6633) // Bullet SmallWait(3) DisplayString(LastHeardBy,40012) // <ITEM-NAME> besides... Continue() RESPONSE #1 SetGlobal("BULL01","LOCALS",1) SetToken("ITEM-NAME",6633) // Bullet SmallWait(3) DisplayString(LastHeardBy,40027) // What is that? <ITEM-NAME>? Continue() RESPONSE #1 SetGlobal("BULL01","LOCALS",1) Continue() END IF Global("FIRST","LOCALS",1) Global("SW1H01","LOCALS",0) HasItem("SW1H01",LastSummonerOf) // Bastard Sword THEN RESPONSE #5 SetGlobal("SW1H01","LOCALS",1) SetToken("ITEM-NAME",6646) // Bastard Sword SmallWait(3) DisplayString(LastHeardBy,40011) // <ITEM-NAME>... Continue() RESPONSE #1 SetGlobal("SW1H01","LOCALS",1) SetToken("ITEM-NAME",6646) // Bastard Sword SmallWait(3) DisplayString(LastHeardBy,40012) // <ITEM-NAME> besides... Continue() RESPONSE #1 SetGlobal("SW1H01","LOCALS",1) SetToken("ITEM-NAME",6646) // Bastard Sword SmallWait(3) DisplayString(LastHeardBy,40027) // What is that? <ITEM-NAME>? Continue() RESPONSE #1 SetGlobal("SW1H01","LOCALS",1) Continue() END IF Global("FIRST","LOCALS",1) Global("LEAT01","LOCALS",0) HasItem("LEAT01",LastSummonerOf) // Leather Armor THEN RESPONSE #5 SetGlobal("LEAT01","LOCALS",1) SetToken("ITEM-NAME",2890) // Leather Armor SmallWait(3) DisplayString(LastHeardBy,40011) // <ITEM-NAME>... Continue() RESPONSE #1 SetGlobal("LEAT01","LOCALS",1) SetToken("ITEM-NAME",2890) // Leather Armor SmallWait(3) DisplayString(LastHeardBy,40012) // <ITEM-NAME> besides... Continue() RESPONSE #1 SetGlobal("LEAT01","LOCALS",1) SetToken("ITEM-NAME",2890) // Leather Armor SmallWait(3) DisplayString(LastHeardBy,40027) // What is that? <ITEM-NAME>? Continue() RESPONSE #1 SetGlobal("LEAT01","LOCALS",1) Continue() END IF Global("FIRST","LOCALS",1) Global("SLNG01","LOCALS",0) HasItem("SLNG01",LastSummonerOf) // Sling THEN RESPONSE #5 SetGlobal("SLNG01","LOCALS",1) SetToken("ITEM-NAME",6733) // Sling SmallWait(3) DisplayString(LastHeardBy,40011) // <ITEM-NAME>... Continue() RESPONSE #1 SetGlobal("SLNG01","LOCALS",1) SetToken("ITEM-NAME",6733) // Sling SmallWait(3) DisplayString(LastHeardBy,40012) // <ITEM-NAME> besides... Continue() RESPONSE #1 SetGlobal("SLNG01","LOCALS",1) SetToken("ITEM-NAME",6733) // Sling SmallWait(3) DisplayString(LastHeardBy,40027) // What is that? <ITEM-NAME>? Continue() RESPONSE #1 SetGlobal("SLNG01","LOCALS",1) Continue() END IF Global("FIRST","LOCALS",1) Global("STAF01","LOCALS",0) HasItem("STAF01",LastSummonerOf) // Quarterstaff THEN RESPONSE #5 SetGlobal("STAF01","LOCALS",1) SetToken("ITEM-NAME",6351) // Quarterstaff SmallWait(3) DisplayString(LastHeardBy,40011) // <ITEM-NAME>... Continue() RESPONSE #1 SetGlobal("STAF01","LOCALS",1) SetToken("ITEM-NAME",6351) // Quarterstaff SmallWait(3) DisplayString(LastHeardBy,40012) // <ITEM-NAME> besides... Continue() RESPONSE #1 SetGlobal("STAF01","LOCALS",1) SetToken("ITEM-NAME",6351) // Quarterstaff SmallWait(3) DisplayString(LastHeardBy,40027) // What is that? <ITEM-NAME>? Continue() RESPONSE #1 SetGlobal("STAF01","LOCALS",1) Continue() END IF True() THEN RESPONSE #2 DisplayString(LastHeardBy,40028) // That's it, I believe. DestroySelf() RESPONSE #2 DisplayString(LastHeardBy,40029) // ...and nothing more. DestroySelf() RESPONSE #2 DisplayString(LastHeardBy,40030) // Nothing more to make out. DestroySelf() END The result is "Quarterstaff" twice before the end and no mention of "Bullet." Rearrange the checks any way, and the first-last items switch places. If I make Tiax drop the quarterstaff, it is the sling that gets announced twice. Does anybody have a clue why the engine cycles the checks in this manner? Edited July 24, 2021 by temnix Quote Link to comment
kjeron Posted July 25, 2021 Share Posted July 25, 2021 You need to move the "SmallWait(3)" down a line, after the "DisplayString()", but still before the "Continue()". At it's current location, the "DisplayString()" from the block above, and the SetToken from the block below, occur simultaneously. When this occurs, the new token takes priority, regardless of the order of the actions. The following will set the token to "Bullet" before the string display occurs: IF True() THEN RESPONSE #100 DisplayString(LastSummonerOf,71626) // <ITEM-NAME>.... SetToken("ITEM-NAME",6633) // Bullet DestroySelf() END As will this: IF True() THEN RESPONSE #100 DisplayString(LastSummonerOf,71626) // <ITEM-NAME>... Continue() END IF True() THEN RESPONSE #100 SetToken("ITEM-NAME",6633) // Bullet DestroySelf() END Quote Link to comment
temnix Posted July 25, 2021 Author Share Posted July 25, 2021 Why does it happen? Well - I will certainly try it. Thank you. Quote Link to comment
Recommended Posts
Join the conversation
You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.