Cutting down a tree script. Help please.

Post » Tue Apr 01, 2014 3:57 pm

Hi all.

I'm in the process of making tree stumps produce resources i.e. logs. So far I've made a tree stump into an activator which when activated gives 1 chopped log once only (obviously they can't respawn). The script worked fine, then I thought I should do an inventory check to make the player possess a Woodcutter's Axe, so I added more lines to the script - unsuccessfully. The script compiles but no log is added to the player's inventory, no notification either whereas previous to me adding the extra lines all worked well. If you guys could look over the script and tell me what is wrong it will be appreciated. Also I'd like that after the tree has been "harvested" it disables and it replaced by a smaller stump (which is on the right in the screenshot), I guess 2 Object references might work but can the stump disable itself?

Screenshot: https://onedrive.live.com/?cid=b60c11d037429d8e#cid=B60C11D037429D8E&id=B60C11D037429D8E%2130657&v=3

Actor property PlayerRef AutoMiscObject Property CutLog AutoWeapon Property WoodAxe AutoAuto State NotEntered            Event OnActivate(objectreference akActionRef)                                       if (PlayerRef.GetItemCount(WoodAxe) > 0)                           Game.GetPlayer().AddItem(CutLog, 1, False)    elseif (PlayerRef.GetItemCount(WoodAxe) == 0)debug.Notification("You need a Woodcutter’s Axe to chop the tree")                           GoToState("")                  endif        EndEvent  EndState

Thanks.

User avatar
Lyndsey Bird
 
Posts: 3539
Joined: Sun Oct 22, 2006 2:57 am

Post » Tue Apr 01, 2014 4:58 pm

I think the "elseif" is useless. Try to put simply "else" without any condition.

Also, I never used a "Actor Property PlayerRef Auto", but "ObjectReference Property PlayerRef Auto" and it works fine (IMO).

Since you've the PlayerRef, replace the Game.GetPlayer() with PlayerRef so.

Last, use a "done" state (also I'm supposing that your GotoState("") is in wrong place).

ObjectReference property PlayerRef AutoMiscObject Property CutLog AutoWeapon Property WoodAxe AutoAuto State NotEntered        Event OnActivate(objectreference akActionRef)                                               if (PlayerRef.GetItemCount(WoodAxe) > 0)            PlayerRef.AddItem(CutLog, 1, False)            GoToState("Done")        else            debug.Notification("You need a Woodcutter’s Axe to chop the tree")                    endif    EndEvent  EndStateState Done    ;EndState
User avatar
Eric Hayes
 
Posts: 3392
Joined: Mon Oct 29, 2007 1:57 am


Return to V - Skyrim