Search an armor in a list ( in a geck script )

Post » Fri May 13, 2011 11:57 pm

Hello everybody !

I have an issue with a script that don't return "1" when searching an armor in a list ...

I first create a list with the item outfitmerc01 (hereticuslist)

An object , when added to an npc inventory do this :

scn nonworkingscript

ref contid
ref armor

begin onadd

set contid to getcontainer ;catch the npc id that have the object

set armor to contid.getequippedobject 2 ; catch the id of the npc armor (NVSE function)

if armor.isinlist hereticuslist ; show the message "test" if the armor is in the list
showmessage test
endif
end



But it don't work at all :( , and when i change the "showmessage test" by "additem (something)" ... kill contid ... or wathever ... it don't work ... :(

BUT , if i do this :

if armor == outfitmerc01
showmessage test
endif


It work , but the list of armors is realy long so the code is not optimized and it's more difficult for me to manage it with the entire code ... a list with all armors is realy better !

Thanks in advance ,

Hereticus
User avatar
benjamin corsini
 
Posts: 3411
Joined: Tue Jul 31, 2007 11:32 pm

Post » Fri May 13, 2011 12:17 pm

http://fose.silverlock.org/fose_command_doc.html#GetEquippedObject returns the ID of the object's base form, which cannot be used to call a reference function like http://geck.gamesas.com/index.php/IsInList. In fact, because it isn't a valid reference, if you try to use it to call a reference function your script will silently stop running.

Try using NVSE's http://fose.silverlock.org/fose_command_doc.html#ListGetFormIndex instead.

Cipscis
User avatar
Eric Hayes
 
Posts: 3392
Joined: Mon Oct 29, 2007 1:57 am

Post » Fri May 13, 2011 4:36 pm

http://fose.silverlock.org/fose_command_doc.html#GetEquippedObject returns the ID of the object's base form, which cannot be used to call a reference function like http://geck.gamesas.com/index.php/IsInList. In fact, because it isn't a valid reference, if you try to use it to call a reference function your script will silently stop running.

Try using NVSE's http://fose.silverlock.org/fose_command_doc.html#ListGetFormIndex instead.

Cipscis


Can you give me a sample when the ListGetFormIndex command can replace mine ? I don't realy see how :s.

Thanks :)
User avatar
Alessandra Botham
 
Posts: 3440
Joined: Mon Nov 13, 2006 6:27 pm

Post » Fri May 13, 2011 5:38 pm

Try this:
ScriptName workingscriptref contidref armorBegin OnAdd	set contid to GetContainer ;catch the npc id that have the object	set armor to contid.GetEquippedObject 2 ; catch the id of the npc armor (NVSE function)	if ListGetFormIndex hereticuslist armor >= 0 ; show the message "test" if the armor is in the list		ShowMessage test	endifEnd
I've assumed that, if the object is the first item in the list, http://fose.silverlock.org/fose_command_doc.html#ListGetFormIndex will return 0, although I'm not absolutely certain this is the case.

Cipscis
User avatar
Taylah Haines
 
Posts: 3439
Joined: Tue Feb 13, 2007 3:10 am

Post » Fri May 13, 2011 9:06 pm

Try this:
ScriptName workingscriptref contidref armorBegin OnAdd	set contid to GetContainer ;catch the npc id that have the object	set armor to contid.GetEquippedObject 2 ; catch the id of the npc armor (NVSE function)	if ListGetFormIndex hereticuslist armor >= 0 ; show the message "test" if the armor is in the list		ShowMessage test	endifEnd
I've assumed that, if the object is the first item in the list, http://fose.silverlock.org/fose_command_doc.html#ListGetFormIndex will return 0, although I'm not absolutely certain this is the case.

Cipscis


Thank you very very very mutch , i'm stuck on this for days ! I will try this this evening :D.

One question : if the value must be >=0 ... what's the value ? Negative one ? simple curiosity ^^.
User avatar
Dylan Markese
 
Posts: 3513
Joined: Sat Dec 01, 2007 11:58 am

Post » Sat May 14, 2011 12:25 am

If the first item has an index of 0, which I expect it does, then I'd expect -1 to indicate that an item is not in the list.

Cipscis
User avatar
dean Cutler
 
Posts: 3411
Joined: Wed Jul 18, 2007 7:29 am

Post » Fri May 13, 2011 4:37 pm

If the first item has an index of 0, which I expect it does, then I'd expect -1 to indicate that an item is not in the list.

Cipscis


Yeah, that's how it works.
User avatar
Emilie Joseph
 
Posts: 3387
Joined: Thu Mar 15, 2007 6:28 am

Post » Fri May 13, 2011 11:48 am

The OP has created a http://www.thenexusforums.com/index.php?/topic/291257-search-an-armor-in-a-list-in-a-geck-script on newvegasnexus where I have suggested a simpler solution. Use getequipped instead of FOSE commands.
User avatar
renee Duhamel
 
Posts: 3371
Joined: Thu Dec 14, 2006 9:12 am

Post » Fri May 13, 2011 3:40 pm

Thank you everybody , the NVSE way work fine , i'll try the non-NVSE way this evening :). Thanks.
User avatar
Jerry Jr. Ortiz
 
Posts: 3457
Joined: Fri Nov 23, 2007 12:39 pm


Return to Fallout: New Vegas