Jump to content

Checking if player has items with keyword.


Recommended Posts

  • Replies 49
  • Created
  • Last Reply

Top Posters In This Topic

I am testing your script and mine, I noted an error in yours in previous post.

Mine is like this....

 

GlobalVariable Property FlintUseCount Auto
GlobalVariable Property FlintInUse Auto
GlobalVariable Property FireULock Auto
Light Property MyTorch Auto
Sound Property MySFX Auto
MiscObject Property EmptyBottle Auto
MiscObject Property Oil Auto
MiscObject Property Rag Auto
MiscObject Property Bristle Auto
MiscObject Property Flint Auto
Message Property EquipTorch Auto
Message Property KindAccList Auto
Message Property NeedKindAcc Auto
Message Property NeedIgnite Auto
Message Property FlintOrTorch Auto
ObjectReference Property MyMarker Auto

Function CombustibleList()
; inventory check to see if player has NONE of the required items – add to as needed
if (Game.GetPlayer().GetItemCount(Rag) < 1) && (Game.GetPlayer().GetItemCount(Oil) < 1) && (Game.GetPlayer().GetItemCount(Bristle) < 1)
NeedKindAcc.Show()
; inventory check to see if player has at least 1 of any combustible item
elseIf (Game.GetPlayer().GetItemCount(Rag) >= 1) || (Game.GetPlayer().GetItemCount(Oil) >= 1) || (Game.GetPlayer().GetItemCount(Bristle) >= 1)
Int iButtonB = KindAccList.Show(); show combustible items menu
If iButtonB == 0
Game.GetPlayer().RemoveItem(Rag, 1) ; remove 1 dry rag
EndIf
If iButtonB == 1
Game.GetPlayer().RemoveItem(Oil, 1, TRUE) ; silently remove 1 oil
Game.GetPlayer().AddItem(EmptyBottle, 1, TRUE) ; silently add empty bottle
debug.notification("Oil Removed")
EndIf
If iButtonB == 2
Game.GetPlayer().RemoveItem(Bristle, 1) ; remove 1 bristle
EndIf
Endif
EndFunction

Function LightFire()
If FlintInUse.GetValue() == 1
MySFX.Play(Self) ; if player chose flint then play flint ignition sound
FlintInUse.SetValue(0); resets variable for futire use
Endif
FireULock.SetValue(1); sets value for next part of the puzzle i.e. “the fire is lit, what is next?”
Utility.Wait(1.5); allow time for sfx to finish
MyMarker.Disable() ; actually show fire light
Self.Disable()
Utility.Wait(0.5)
Self.Delete()
EndFunction

Auto State Waiting
Event OnActivate(ObjectReference akActionRef)
if (Game.GetPlayer().GetItemCount(MyTorch) < 1) && (Game.GetPlayer().GetItemCount(Flint) < 1)
NeedIgnite.Show(); player has no ignite source
else
Int iButtonA = FlintOrTorch.Show(); show ignition source menu
; menu is shown with available ignite sources based on conditions set in message form
If iButtonA == 0 && (Game.GetPlayer().GetEquippedItemType(0) != 11)
EquipTorch.Show(); show equip torch message
GoToState("Waiting") ; After the Message Above will EXIT to be activated again
elseIf iButtonA == 0 && (Game.GetPlayer().GetEquippedItemType(0) == 11)
CombustibleList()
LightFire()
elseIf iButtonA == 1 && (Game.GetPlayer().GetItemCount(Flint) > 0)
FlintUseCount.Mod(1); counts how many times this piece of flint has been used
FlintInUse.SetValue(1); flint is GOING TO BE USED – needed for condition later on
CombustibleList()

LightFire()
EndIf
EndIf

EndEvent
EndState

 

 

Has issue that if player has no combustible items lights fire anyway.

Link to comment
Share on other sites

Glad you could made it work by yourself !, and sorry for taking me so much time to actually understand what you wanted the script to do...


* The last script i posted is been rectified. Typo double written.


* "Has issue that if player has no combustible items lights fire anyway."

That's impossible, if no item WILL EXIT.



If Game.GetPlayer().GetItemCount(Rag) > 0
Game.GetPlayer().RemoveItem(Rag, 1)
Debug.Notification ("Option 0, 1 Dry Rag remove")
LitFire() ; If this option is choose will go to execute the enable/disable - play - delete - etc.. "Function LitFire()"
Else
Debug.Notification ("You don't have Rag")
GoToState("Waiting") ; Will EXIT if there is no item
EndIf


Edited by maxarturo
Link to comment
Share on other sites

The Script has been compiled and tested.


- I made 2 "Message MENUS".

One for "Torch or Flint" and One for the 3 "Combastable Items".


- 3 Messages for when items are remove.


- And 5 "No Item in Inventory" messages.

One for each ITEM.


And is doing exactly what you want it to do.


* I did not use your properties, but i made my own PROPERTIES to match everything as the script is made.


* In the posted version i use " Debug.Notification () " so you can arrange your own messages.

Edited by maxarturo
Link to comment
Share on other sites

Does not show "Equip Torch" message and continues without MAKING the player equip a torch.

This line...

 

If Game.GetPlayer().GetEquippedItemType(0) != 11

MyCombustibleMenu() ; Goes to the choose combastion items MENU if TORCH is equiped "MyCombustibleMenu()"

 

Does the opposite of the description. It says 'If torch is NOT equipped then continue.

Should be...

 

If Game.GetPlayer().GetEquippedItemType(0) == 11

MyCombustibleMenu() ; Goes to the choose combastion items MENU if TORCH is equiped "MyCombustibleMenu()"

If torch IS equipped then continue.

ANYWAY.....

This is the definitive version of the script, trimmed off 'the fat', tested it quite a bit and every possible option (has no ignite source, has torch, has flint, has torch and flint, has no combustibles, has some combustibles, has all available combustibles) are covered.

Thanks a million for your help, I couldn't have done it without you, plus it helped me write 2 or 3 other similar scripts while we were battling this one.

GlobalVariable Property FlintUseCount Auto
GlobalVariable Property FireULock Auto
GlobalVariable Property FlintInUse Auto
Light Property MyTorch Auto
Sound Property MySFX Auto
MiscObject Property Oil Auto
MiscObject Property EmptyBottle Auto
MiscObject Property Rag Auto
MiscObject Property Bristle Auto
MiscObject Property Flint Auto
Message Property EquipTorch Auto
Message Property CombustMenu Auto
Message Property NeedKindAcc Auto
Message Property NeedIgnite Auto
Message Property FlintOrTorch Auto
Message Property ReqItemsMsg Auto
Message Property NoReqIgniteItems Auto
ObjectReference Property MyMarker Auto


Auto State Waiting
Event OnActivate(ObjectReference akActionRef)
if (akActionRef == Game.GetPlayer())

if (Game.GetPlayer().GetItemCount(MyTorch) > 0) || (Game.GetPlayer().GetItemCount(Flint) > 0)
MyIgnitesItem() ; If player has ignition source will go to "MyIgnitesItem()"

else
NoReqIgniteItems.Show() ; no ignition source
GoToState("Waiting")
Endif
Endif
EndEvent
EndState


State Busy
Event OnActivate(ObjectReference akActionRef)
;Do nothing.
EndEvent
EndState


Function MyIgnitesItem()
GoToState("Busy")
Int iButtonA = FlintOrTorch.Show()
If iButtonA == 0
If Game.GetPlayer().GetEquippedItemType(0) == 11
MyCombustibleMenu() ; Goes to the choose combustion items MENU if TORCH is equipped "MyCombustibleMenu()"
else
EquipTorch.Show(); If Torch is NOT EQUIPED, Player should "Equip the Torch" Message will show
GoToState("Waiting"); After the Message Above will EXIT to be activated again
EndIf
EndIf
If iButtonA == 1
If Game.GetPlayer().GetItemCount(Flint) > 0
FlintInUse.SetValue(1); sets variable for Flint sfx to play IF lighting fire succeeds
Debug.Notification ("Using Flint To Light Fire")
MyCombustibleMenu() ; player chose flint and has flint so goes to combustible items menu
EndIf
EndIf
EndFunction


Function MyCombustibleMenu()
Int iButtonB = CombustMenu.Show()
If iButtonB == 0
Game.GetPlayer().RemoveItem(Rag, 1, TRUE)
debug.notification("Rag Used As Kindling")
LitFire() ; If this option is choose will go to "Function LitFire()"
EndIf

If iButtonB == 1
Game.GetPlayer().RemoveItem(Oil, 1, TRUE)
Game.GetPlayer().AddItem(EmptyBottle, 1, TRUE)
debug.notification("Oil used as accelerant")
LitFire() ; If this option is choose will go to "Function LitFire()"
EndIf

If iButtonB == 2
Game.GetPlayer().RemoveItem(Bristle, 1, TRUE)
debug.notification("Bristles Used As Kindling")
LitFire() ; If this option is choose will go to "Function LitFire()"
EndIf

if (Game.GetPlayer().GetItemCount(Rag) < 1) && (Game.GetPlayer().GetItemCount(Oil) < 1) &&(Game.GetPlayer().GetItemCount(Bristle) < 1)
FlintInUse.SetValue(0); resets variable for Flint sfx to play because lighting fire was unsuccessful
NeedKindAcc.show()
Endif

GoToState("Waiting")
EndFunction


Function LitFire()

; Do Stuff Here
If FlintInUse.GetValue() == 1
MySFX.Play(Self) ; if player chose flint then play flint ignition sound
FlintInUse.SetValue(0); resets variable for future use
FlintUseCount.Mod(1) ; counting how many times this piece of flint has been used
Endif
FireULock.SetValue(1); sets value for next part of the puzzle i.e. “the fire is lit, what is next?”
Utility.Wait(1.5); allow time for sfx to finish
MyMarker.Disable() ; actually show fire light
Self.Disable()
Utility.Wait(0.5)
Self.Delete()

EndFunction

Link to comment
Share on other sites

Congrats !.

But now that you are done with it i have a confession to make that you'll hate me or curse me for it.


In the Final Script i intentionally threw in 2 mistakes an "EndState" intead of "EndEvent" and i didn't change one operator (my initial thought was to change all operators but i didn't, cause i didn't want to make your head explode), just to force you to search for it and give your best to try and make it work.


I really hope that all of this helped you advance - level up your Scripting abilitys and that you now have a better and deeper understanding of how scripts works and are made. (remember ORDER).


Please don't hate me for it... and keep on pressing forwards !.


Have a happy modding !.

Edited by maxarturo
Link to comment
Share on other sites

I don't hate you for it, I just thought you were pretty dumb. LOL

Seriously, I thought at times "There's some s**t here that has no reason being here.". Hence my quote in my previous post "trimmed off the fat."

Sifting through the script took me back to, wait for it - this will show my age now, when I used to program in BASIC (Beginners All-Purpose Symbolic Instruction Code). This was the language used by Atari Pcs. Yes Atari PCs, I had the 800XL with a whopping 64k, that's K not MB or GB of ram. I programmed the hell out of it until I repeatedly got the message 'Out of system memory' for what I was doing. The 'function' in papyrus is the same as 'gosub' (go sub-routine) in BASIC.

So it has been a re-learning curve, you ain't as dumb as I thought you were and neither am I. :thumbsup:

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...