Jump to content

Beehive and Cow Script


Recommended Posts

Scriptname AB0000Bienenstock extends ObjectReference  

GlobalVariable property GameDaysPassed auto
Potion Property FoodHoney Auto
Ingredient Property BeeHoneyComb Auto
int Property TG02BeeHive Auto

EventOnBaseItem()AddItem(akFoodHoney, akBeeHoneyComb, aiCount, abSilent)
    
    IFGameDaysPassed.GetValue() == 1
    akBaseItem.AddItem == FoodHoney
  EndIf
     Endwhile
    IfGameDaysPassed.GetValue() == 5
    akBaseItem.AddItem == BeeHoneyComb
  EndIf
     Endwhile

EndEvent

 

This is my script of my beehive, but it doesn't seem to compile. It should spawn honey once after one ingame day and a honeycomb after 5 ingame days.
With the cow milking script I am stuck on whether it is an Actor or ObjectReference script. Since I have found independent scripts of both as illustrative material. 
I would therefore be grateful for any help and tips.

Link to comment
Share on other sites

there nothing to fix in that script, it's unrepairable.. bin it and start again

you need to track the last day it was harvested, what is the day today, and if enough days has elapsed, give the player some sweet honey .. with an on activate event, or verbose the  hive is empty come back tomorrow..

try debugging days passed so you know the compare value for the honey and honeycombs and below is your logic converted into pseudo code

13 hours ago, Dark09188 said:

It should spawn honey once after one ingame day and a honeycomb after 5 ingame days.

 

add script to bee hive

public property days passed
public property honey
public property honeycomb
public property Player

private variable honey day last harvested
private variable honeycomb day last harvested

Event On Activate

    if days passed is 1 time greater last harvested Honey

        add honey to the player
        set honey was harvested today

    end if

    if days passed is 5 times greater than last harvested Honeycomb

        add honeycomb to the player
        set honeycomb was harvested today
        
    end if

End Event

now you need to convert that pseudo code into papyrus, so think about your logic, write it has fake code, then convert it to the real thing  only think about the action you want too..

Quote

On looking in the honey hive it should spawn honey once after one ingame day and a honeycomb after 5 ingame days

Papyrus is object orientated and imitates the real world, thinking in real world terms is great way to set the logic out before writing actual code

The pseudo code needs to be really bland and non-specific and applicable to every coding language under the sun, within reason, it just setting out the most basic simple structure, do not be surprised if the finished code looks nothing like it..

 

Link to comment
Share on other sites

Edit you need to think about the initialisation values of private variables too,  so the code works for the first time, since they set, when an object is harvested for the first time, they need a default value. it is simply done like so

int numberA = 10
float  numberB = 12.3456

there no need for an OnInit Event, just declare them at top of the script, where you LOL you declare them, if say you want the code to work for testing on day 1 of game day passed? Applied common sense dictate the initialisation values are

int honeyLastedHarvested = -1
int honeycombLastedHarvested = -5

cause just incorrectly setting them can be a 

Quote

OH MY GOD THE CODE DOES NOT WORK AND DON'T KNOW WHY

for a newbie

Link to comment
Share on other sites

Posted (edited)

Scriptname AB0000Bienenstock extends ObjectReference  

GlobalVariable property GameDaysPassed auto
Potion Property FoodHoney Auto
Ingredient Property BeeHoneyComb Auto
ObjectReference Property tg02beehive Auto
int honeyLastedHarvested = 0
int honeycombLastedHarvested = 0

EventOnObjectReference.AddItem(akFoodHoney, akBeeHoneyComb, aiCount, abSilent)
    
    if GameDaysPassed.GetValue() >= + 1.0
    ObjectReference.AddItem == FoodHoney
    lastharvested = GameDaysPassed.GetValue()
    
  EndIf
     Endwhile
    if GameDaysPassed.GetValue() >= 5.0
    ObjectReference.AddItem == BeeHoneyComb
    lastharvested = GameDaysPassed.GetValue()
 EndIf
     Endwhile

EndEvent

 

I don't understand what I'm doing wrong. Because there is always an error in the same line (in the “EventOn” line). The honey and the honeycomb should also only be added (spawn) inside the hive, so that you can view and take the content when you click on it. What I have specified in the script with the beehive as ObjectReference. 

I even copied the lines from the Creation Kit Wiki so that it is spelled correctly, but there is always a “.” or “(”  the error.

 

Scriptname AB0000Bienenstock extends ObjectReference  

GlobalVariable property GameDaysPassed auto
Potion Property FoodHoney Auto
Ingredient Property BeeHoneyComb Auto
ObjectReference Property tg02beehive Auto
int honeyLastedHarvested = 0
int honeycombLastedHarvested = 0

EventOnGame.GetObjectReference().AddItem((FoodHoney), BeeHoneyComb 1, true)
    if GameDaysPassed.GetValue() >= + 1.0
    ObjectReference.AddItem == FoodHoney
    lastharvested = GameDaysPassed.GetValue()
    
  EndIf
     Endwhile
    if GameDaysPassed.GetValue() >= 5.0
    ObjectReference.AddItem == BeeHoneyComb
    lastharvested = GameDaysPassed.GetValue()
 EndIf

EndEvent

That was the new try

Errorr: "no viable alternative at input "."

 

Edited by Dark09188
Link to comment
Share on other sites

LOL

Scriptname BeeHiveScript extends ObjectReference
{add this to bee hive in the cell window} 

GlobalVariable property GameDaysPassed auto
Potion Property FoodHoney Auto
Ingredient Property BeeHoneyComb Auto

int honeyLastedHarvested = -1
int honeycombLastedHarvested = -5

; On activating the bee hive

Event OnActivate(ObjectReference akActionRef)

   if akActionRef != Game.GetPlayer()
      ; If it is not the player stop the script from running
      return
   EndIf
   ; we now know the akActionRef is the Player

   ; get the current days passed
   int daysPassed=GameDaysPassed.GetValue() as int

   ; if the day is greater than last harvested plus the cool down
   if daysPassed >= honeyLastedHarvested + 1

      ; add honey to tho player
      akActionRef.AddItem(FoodHoney)

      ; set the value as harvested today
      honeyLastedHarvested = daysPassed
   EndIf

   ; rinse and repeat for honeycomb
   if daysPassed >= honeycombLastedHarvested + 5
      akActionRef.AddItem(BeeHoneyComb)
      honeycombLastedHarvested = daysPassed
   EndIf

EndEvent

 

Link to comment
Share on other sites

LOL making the default Private variable 0, that might be better or not, cause for testing on the first day, assuming that is day 0 plus the cool down mean days passed needs to 1 and 5 respectively for the code to work. that why I did what I did, I am also assuming on the first game day, no days have passed so it is a 0

 

Link to comment
Share on other sites

you walk up to the hive and activate it, from there what are you trying to achieve?

  1. open another menu with the contents of the hive
  2. or harvest it?

I went with harvest option..  if that not what your after, you need to be more specific, and exactly what UI menu displaying the contents of the hive are you thinking of?

Link to comment
Share on other sites

I'm more Option 1. So you go to the hive, activate it, it shows a menu like in the normal game, and each day should one honey and each fitfth day should be a BeeHoneyComb in the menu. Then i can take the items or let it in. 

Link to comment
Share on other sites

when it come to menu you mean a vanilla message box where players can input their choice, If available?

yeah it can done, BUT it will require either a 

https://ck.uesp.net/wiki/GetVMQuestVariable

or 

https://ck.uesp.net/wiki/GetVMScriptVariable

to set the conditions in the message box or any other menu, and it is starting to complicated,  are you sure you are up for this? 

Has you can see on looking at those pages there is sweet nada info on how this works.. and it is combination Papyrus telling the Game Engine what are the CK message box conditions, that are that are set in Creation Kit

But basically on activating the beehive it  triggers conditional Papyrus Code that tells the Game Engine then uses with the message box conditions, which  set which option are displayed

then the menu opens with your optional harvest so if an item cannot be harvested, it will not display, and if no harvest options are available it will just state that with maybe (getting more complicated) when how days must passt for the item to come to  fruition

Like I said getting complicated 

https://ck.uesp.net/wiki/Show_-_Message

Note the argument options, that how you set the days to return in the vanilla menu, and you can see 99% of the page is explaining how they work.

And setting the Arguments in the message to display is the easy part of all of this.

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

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