Jump to content

[LE] Need help with ShowGiftMenu


Lulde

Recommended Posts

Greetings!

 

I'm already getting desperate with this, so I have to ask help. I'm just a beginner with modding, so I have only followed some tutorials to get familiar with CK so far.

 

So, I'm trying to make a mod for an animal follower, in this case I have a little chicken friend and I would like to feed her. I followed one YouTube tutorial to get to this point in this mod, but in the tutorial there was a trade option for a follower, and I want to give a gift. So I tried to do the "trade" script on my own, using the ShowGiftMenu function.

 

My script is under DialogueFollower quest, in DialogueFollowerTrade. In the tutorial, he put a line of script in the End > Papyrus Fragment, but I don't have anything in there right now, I tried to put "ShowGiftMenu(True, FoodList, False, False)" there but it didn't help. When I talk to my chicken, the dialogue opens up, and other options work fine, but when I try to offer her food, nothing happens and the menu doesn't open.

Scriptname ChickenFriend_Trade Extends Actor

FormList Property FoodList Auto

Function Fragment_3()
AddInventoryEventFilter(FoodList)
ShowGiftMenu(True, FoodList, False, False)
RemoveAllInventoryEventFilters()
EndFunction

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
If akSourceContainer == Game.GetPlayer()
self.RemoveItem(akBaseItem,aiItemCount)
EndIf
EndEvent

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 4
Scriptname ChickenFriend_Trade Extends TopicInfo Hidden

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

 

I would really appreciate if someone could help me with this, thank you in advance! :smile:

 

Edit: why my script looks so horrible with every second line white? Sorry about that

Edited by Lulde
Link to comment
Share on other sites

Hello, It has been a few months since I opened up the Creation Kit, so my memory may be a little foggy, but I will try to be of much help as I can. :smile:

While not a requirement, it may be easier to create a separate quest for your follower entirely so you have more control over the quest. Not only that, but for compatibility with other plugins that utilize the DialogueFollower Quest as well.

I created a similar script for a custom follower ages ago which I am going to go over in this thread to help you out.

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 1
Scriptname MYFOLLOWERDRINK01 Extends TopicInfo Hidden

;BEGIN FRAGMENT Fragment_0
Function Fragment_0(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
akspeaker.ShowGiftMenu(true, AlcoholicDrinksList)
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

FormList Property AlcoholicDrinksList  Auto

In your script, you have a similar function which is all you really need in order for it to work but you are missing a property that adds your follower to your script.

Function Fragment_3()
AddInventoryEventFilter(FoodList)
ShowGiftMenu(True, FoodList, False, False)
RemoveAllInventoryEventFilters()
EndFunction

ShowGiftMenu is a function and needs to be attached to a property, but currently it's not attached to anything. How can ShowGiftMenu show a list of food to your follower to give to your follower if they do not exist inside of your script?

 

You can add your follower by creating an Actor Property in the properties tab of your script. It will appear as the following line in your script: Actor Property MyCustomName Auto.

 

Alternatively, you can add the line Actor akSpeaker = akSpeakerRef as Actor to your script.

akSpeaker: This is the Actor that is speaking the topic. (May be None if the speaker isn't an Actor - in which case, check akSpeakerRef)
akSpeakerRef: This is the ObjectReference that is speaking the topic. Will be the same object as akSpeaker.

Taken from the ShowGiftMenu section on the Creation Kit WIKI (https://www.creationkit.com/index.php?title=ShowGiftMenu_-_Actor)

; Shows the give gift menu for Bob, filtering for food
Bob.ShowGiftMenu(true, OnlyFoodList)

In this example, they have added their follower to the script by creating an Actor Property called "Bob" and attached the function ShowGiftMenu to Bob. Therefore, it will only show OnlyFoodList to Bob.

 

In my script, I add my follower to the script through the line Actor akSpeaker = akSpeakerRef as Actor and attached ShowGiftMenu to akSpeaker. Therefore, it will only show AlcoholicDrinksList to akSpeaker.

 

I also chose this example, because I am making the assumption you are trying to make it so it only shows a list of food from the foodlist, which is exactly what this example does. There is no need for any additional lines.

 

What are you trying to achieve with this event?

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
If akSourceContainer == Game.GetPlayer()
self.RemoveItem(akBaseItem,aiItemCount)
EndIf
EndEvent

Finally, your script is trying to exend both the actor as well as the topicinfo.

Scriptname ChickenFriend_Trade Extends Actor
Scriptname ChickenFriend_Trade Extends TopicInfo Hidden

You only need it to extend the TopicInfo since it is attached to a dialogue topic.

 

So, I would write your script as either:

Scriptname ChickenFriend_Trade Extends TopicInfo Hidden

Actor Property ChickenFriend Auto
FormList Property FoodList Auto

Function Fragment_0()
   ChickenFriend.ShowGiftMenu(true, FoodList)
EndFunction

or

Scriptname ChickenFriend_Trade Extends TopicInfo Hidden

Function Fragment_0(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
   akspeaker.ShowGiftMenu(true, FoodList)
EndFunction

Relevant Links:

https://www.creationkit.com/index.php?title=Topic_Info_Fragments

https://www.creationkit.com/index.php?title=Scripts#Add_Property

https://www.creationkit.com/index.php?title=ShowGiftMenu_-_Actor

Link to comment
Share on other sites

Thank you so much, that was very helpful!

 

Of course I should have known that the function needs the follower there, heh. But anyway, it almost works as I wanted it to, ShowGiftMenu works, I can give a gift to my chicken, but the problem is that it doesn't filter only the food list. I can give other stuff as well.

Scriptname ChickenFriend_GiveFood Extends TopicInfo Hidden

Function Fragment_0(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
   akspeaker.ShowGiftMenu(true, OnlyFoodList)
EndFunction

FormList Property OnlyFoodList Auto
Link to comment
Share on other sites

No worries! I am glad to help in any way I can, as scripting can be tricky. :smile:

 

Make sure your Formlist Property is connected to OnlyFoodList in the Properties Tab:

foodlistproperty.png

 

Check what is inside of your OnlyFoodList, and make sure it only has the food you want to give to your chicken inside of it.

 

foodlistlist.png

 

If you do not have any of the foods in this list in your inventory, usually it will show a blank window when you try to give them a gift.

EMPTYMENU.png

 

However, if you do have these foods in your inventory, it will show them when you try to give them a gift.

WLEEKS.png

 

 

I have created a quick video demonstrating it.

 

Hopefully this helps!

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...