antstubell Posted September 11, 2020 Share Posted September 11, 2020 Made a carriable lantern by duplicating torch01, altering mesh in Nifskope, duplicating torch01 and using my new lantern .nif. Works perfect... but... I now realise that adding a new object to the game when existing scripting has not taken into account that this object ever existed is a problem. I'll explain.In one of my scripts which is used a lot in the mod player is checked to see if they are holding a torch...GetEquippedItemType(0) == 11It appears that my new lantern is not treated as the same type. The script is way more complex than this but for now I'm trying to resolve the question "Is my lantern treated as a torch?" and then I can proceed to iron out any conditional checks. It seems item types are fixed and are limited. Is there a way to assign an item type value to an object? How can I check the item type ID of my lantern?Thanks. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 11, 2020 Share Posted September 11, 2020 Duplicates should be caught as the same type as the original else mod add weapons, shields, spells etc would never be recognized. But it is always possible that with enough changes to the record, it may not be recognized. Unfortunately, I do not know what GetEquippedItemType actually looks for. Is it a pre-defined keyword? Is it a value on the NIF file itself? Is it the type of animation used? Is it a combination of these things? No idea. Perhaps the only way to know would be to dig into the EXE and see what data makes an item qualify for one of the item types. All that said, your lantern is a known object. Can you not add an additional condition to check for it? ;myLantern -- either make a property and assign the base light record or use GetFormFromFile to assign the correct base light record If (PlayerRef.GetEquippedItemType(0) == 11) || (PlayerRef.GetEquippedObject(0) as Light == myLantern) Debug.Notification("Player is carrying a light") EndIf Link to comment Share on other sites More sharing options...
antstubell Posted September 12, 2020 Author Share Posted September 12, 2020 All good advice. I'll get onto it. Thanks. Link to comment Share on other sites More sharing options...
lofgren Posted September 13, 2020 Share Posted September 13, 2020 The condition function that runs on spells and perks and returns the same numerical values detects animation type, but if that was the case for the papyrus version then I would have thought your lantern would be treated as a torch. I know for example IsTorchOut recognizes other lights besides the basic torch. "Is my lantern a torch" sounds like a very challenging philosophical question. Link to comment Share on other sites More sharing options...
antstubell Posted September 13, 2020 Author Share Posted September 13, 2020 Ishara,Couple of errors with the script you posted. I won't post my script here as it is massively long. GetEquippedObject is not a function or does not exist cannot cast a none to a light, types are incompatible Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 13, 2020 Share Posted September 13, 2020 GetEquippedObject does indeed exist. You may not be compiling with SKSE source scripts available. If you are wanting to avoid SKSE, you're going to have to go about things the "long way". On a player alias script use the OnObjectEquipped and OnObjectUnequipped events and compare the equipped / unequipped object to your known lantern. Set a global variable to 1 when equipped and to 0 when unequipped. Use the global variable on the script being discussed in this thread to catch whether the player has a torch or your known lantern equipped. Link to comment Share on other sites More sharing options...
antstubell Posted September 19, 2020 Author Share Posted September 19, 2020 (edited) I wrote a small script to check that the lantern I made from a torch .nif are the same. Getting strange result. Light Property Torch01 AutoLight Property My_LanternCarry2m AutoString Property NoFlame AutoString Property EquipFlame AutoAuto State WaitingEvent OnActivate(ObjectReference akActionRef); check if player has naked flame in inventoryIf (Game.GetPlayer().GetItemCount(Torch01) < 1) && (Game.GetPlayer().GetItemCount(My_LanternCarry2m) < 1)debug.notification(NoFlame); check player has either torch or lantern equippedElseIf (Game.GetPlayer().GetItemCount(Torch01) > 0) || (Game.GetPlayer().GetItemCount(My_LanternCarry2m) > 0) && (Game.GetPlayer().GetEquippedItemType(0) != 11)debug.notification(EquipFlame)EndIfGoToState("Waiting")EndEventEndState What happens is this. If player has no flame source then the message "You Need A Naked Flame" appears. If player has a lantern that is not equipped then the message "Equip Your Flame Source" appears. Player equips lantern and well nothing... because I haven't scripted that far ahead but no message is good. If player equips a vanilla Torch01 then the message "Equip Your Flame Source" appears.This script is way to simple to have an error isn't it?Why isn't the torch recognised as type 11? EDIT: I added this condition to the script. If (Game.GetPlayer().GetEquippedItemType(0) == 11)Debug.Notification ("Type 11 equipped")EndIf Now when torch is equipped I get both messages "Equip Your Flame Source" and "Type 11 equipped" Edited September 19, 2020 by antstubell Link to comment Share on other sites More sharing options...
IsharaMeradin Posted September 20, 2020 Share Posted September 20, 2020 Try this for your debug testing purposes: Light Property Torch01 Auto Light Property My_LanternCarry2m Auto String Property NoFlame Auto String Property EquipFlame Auto Auto State Waiting Event OnActivate(ObjectReference akActionRef) If akActionRef == Game.GetPlayer() ; check if player does not have torch or lantern in inventory If (akActionRef.GetItemCount(Torch01) < 1) && (akActionRef.GetItemCount(My_LanternCarry2m) < 1) debug.notification(NoFlame) ; check if player has either torch or lantern in inventory ElseIf (akActionRef.GetItemCount(Torch01) > 0) || (akActionRef.GetItemCount(My_LanternCarry2m) > 0) ; check if light is not equipped If (akActionRef.GetEquippedItemType(0) != 11) debug.notification(EquipFlame) ; check if light is equipped ElseIf (akActionRef.GetEquippedItemType(0) == 11) Debug.Notification ("Type 11 equipped") EndIf EndIf EndIf EndEvent EndState Link to comment Share on other sites More sharing options...
antstubell Posted September 21, 2020 Author Share Posted September 21, 2020 Got these errors- (21,32): GetEquippedItemType is not a function or does not exist(21,55): cannot compare a none to a int (cast missing or types unrelated)(25,36): GetEquippedItemType is not a function or does not exist(25,59): cannot compare a none to a int (cast missing or types unrelated) Link to comment Share on other sites More sharing options...
antstubell Posted September 21, 2020 Author Share Posted September 21, 2020 (edited) I've another example to show. Same problem but a little more confusing it seems that the lantern is 'treated' differently depending on if it is equipped or not.This video will explain more.https://onedrive.live.com/?cid=B60C11D037429D8E&id=B60C11D037429D8E%2153141&parId=B60C11D037429D8E%21191&o=OneUp Oops. Forgot the script. ObjectReference Property LitMarker AutoObjectReference Property UnlitMarker AutoLight Property HasTorch AutoLight Property HasLantern AutoObjectReference Property LSource AutoObjectReference Property PlaySNDHere AutoMessage Property EquipTorch AutoMessage Property NeedFlame AutoSound Property CandleSND AutoBool Property SelfDis = True AutoBool Property SelfDel = True AutoAuto State WaitingEvent OnActivate(ObjectReference akActionRef)If (Game.GetPlayer().GetEquippedItemType(0) == 11)LitMarker.disable()UnlitMarker.enable(); optionalLSource.enable()CandleSND.Play(PlaySNDHere); optional; player has torch or lantern equipped candle lightsIf SelfDis == Trueself.Disable()EndIfIf SelfDel == Trueself.Delete()EndIfElseIf (Game.GetPlayer().GetItemCount(HasTorch) < 1) && (Game.GetPlayer().GetItemCount(HasLantern) < 1)NeedFlame.show(); player does not have a torch or lanternElseIf (Game.GetPlayer().GetItemCount(HasTorch) >= 1) || (Game.GetPlayer().GetItemCount(HasTorch) >= 1) && (Game.GetPlayer().GetEquippedItemType(0) != 11)EquipTorch.show(); player has torch or lantern but not equippedEndifEndEventEndState Edited September 21, 2020 by antstubell Link to comment Share on other sites More sharing options...
Recommended Posts