Jump to content

Struggling to get my head around this, looking for help.


Job4aCowboy

Recommended Posts

Hey, I'm trying to learn scripting. I'm not doing to bad, written a few scripts myself that function as intended. But the one I'm working on now is giving me all kinds of problems.

 

What I'm trying to do is put a script on a container object; the script will check if the player has the required items to open the container, if they do, it opens. If they don't a message will display (like the pickaxe/wood chopping message)

 

I have properties set up to define what message to display and what form list to look in for the required items.

 

I am trying to use blockactivation(true) to block the activation of the chest (which is working), and if the player has the tools, use "blockactivation(false)" to enable activation.

 

Anyway here is the script so far,

 

Scriptname J4ACGraveRobbersScript2 extends ObjectReference
{Script attached to GraveActivator, checks to see if player has required items...}

formlist property SEEFORMLISTGravetools auto
{Player must have at least one item from this formlist to interact}

Message Property SEEMESSAGEGraverobfailure Auto  
{Message to say why you can't use this without RequiredWeapon}

Keyword Property linkedRefKeyword Auto
{Chest that is linked to Grave Activator}

Event OnLoad()
	Utility.wait(0.50)
	BlockActivation(true)

EndEvent

Event onActivate(objectReference akActivator)
		if (akActivator as Actor) == game.getPlayer()
			if akActivator.GetItemCount(SEEFORMLISTGravetools) < 1
				SEEMESSAGEGraverobfailure.Show()
				gotostate("notools")
			else
				gotostate("Access")
			endIf
		endIf
endEvent

STATE notools
EndState

STATE access
	Event OnBeginState(objectReference akActivator)
		BlockActivation(false)
		Self.activate(akactivator)
		GoToState("block")
	Endevent
EndState


STATE block
	Event OnBeginState()
		BlockActivation(true)
	EndEvent
EndState

 

 

As it stands it blocks the activation and displays the message if the player doesn't have the tools, and doesn't if the player has them. But it never opens the chest.

 

To sum it up;

Player attempts to open container...

Script checks if they have required item(s)

If they do the container opens automatically

If they don't the failure message is displayed

 

 

If anyone can help that'd be great, I'm really trying to learn this papyrus scripting, but apart from the tutorials on the Creation Kit Website (which are OK for a starting point, but that's it), I can't find anything else. So I feel kind of on my own.

 

Thanks

 

 

 

 

 

Job4aCowboy

Link to comment
Share on other sites

STATE access
	Event OnBeginState(objectReference akActivator)
		BlockActivation(false)
		Self.activate(akactivator)
		GoToState("block")
	Endevent
EndState

The above makes no sense to me. Try this:

 

STATE access
	Event OnBeginState(objectReference akActivator)
		BlockActivation(false)
		GraveActivator.activate(akactivator)
                Utility.Wait(5.0)
		GoToState("block")
	Endevent
EndState

Still seems weird. The CK's documentation on these features is dodgy. At best.

Edited by FiftyTifty
Link to comment
Share on other sites

 

STATE access
	Event OnBeginState(objectReference akActivator)
		BlockActivation(false)
		Self.activate(akactivator)
		GoToState("block")
	Endevent
EndState

The above makes no sense to me. Try this:

 

STATE access
	Event OnBeginState(objectReference akActivator)
		BlockActivation(false)
		GraveActivator.activate(akactivator)
                Utility.Wait(5.0)
		GoToState("block")
	Endevent
EndState

Still seems weird. The CK's documentation on these features is dodgy. At best.

 

Sorry, The "grave activator" property is just left over from the old script. so ignore that part.

 

Think I posted the wrong code, it doesn't even compile now.

 

This is the correct script...

 

Scriptname J4ACGraveRobbersScript2 extends ObjectReference
{Script attached to GraveActivator, checks to see if player has required items...}

formlist property SEEFORMLISTGravetools auto
{Player must have at least one item from this formlist to interact}

Message Property SEEMESSAGEGraverobfailure Auto  
{Message to say why you can't use this without RequiredWeapon}

Event OnLoad()
	Utility.wait(0.50)
	BlockActivation(true)

EndEvent

Event onActivate(objectReference akActivator)
		if (akActivator as Actor) == game.getPlayer()
			if akActivator.GetItemCount(SEEFORMLISTGravetools) < 1
				SEEMESSAGEGraverobfailure.Show()
				gotostate("notools")
			else
				gotostate("Access")
			endIf
		endIf
endEvent

STATE notools
EndState

STATE access
	Event OnBeginState()
		BlockActivation(false)
		GoToState("block")
	Endevent
EndState


STATE block
	Event OnBeginState()
		BlockActivation(true)
	EndEvent
EndState

Link to comment
Share on other sites

Well, this one is easy. The container isn't being activated because it isn't being activated; you haven't scripted that part in.

 

But if i script that, it either opens repeatedly forever, or the player has to activate the chest again to open the menu, i need it to be a automatic thing.

 

Also adding (object reference akactivator) to onbeginstate won't compile. and just have onbeginstate() followed by self.activate() throws out a compile error too.

Link to comment
Share on other sites

you need to pass a parameter to the self.activate() so you need to have it be self.activate(Objectreference akActivator) it should then compile

 

one pother thing though, I would suggest getting rid of the block and notools states, currently you have no way for the script to jump out of them and so if the player ever ties to access the grave without the tool they won't be able to dig it up when they come back with the tools

Edited by Hangman4358
Link to comment
Share on other sites

 

STATE access
	Event OnBeginState()
		BlockActivation(false)
                YourContainerPropertyHere.Activate Player
                Utility.Wait(5.0)
		GoToState("block")
	Endevent
EndState

Give that a shot.

 

Im getting confused now. Why do I need a container property. This script will be attached to the container.

 

you need to pass a parameter to the self.activate() so you need to have it be self.activate(Objectreference akActivator) it should then compile

 

one pother thing though, I would suggest getting rid of the block and notools states, currently you have no way for the script to jump out of them and so if the player ever ties to access the grave without the tool they won't be able to dig it up when they come back with the tools

 

Yes I thought this too, but jumping it back to the other states just loops it, and cause the chest to activate over and over.

Link to comment
Share on other sites

I'm going to be using this script on more than one container, so it needs to run on the container object.

 

I've got a working script that sits on a trigger that the player can activate, Checks for said tools and this activates the chest.

 

Hope this makes sense. I'm finding this scripting stuff incredibly hard. It would help if I knew what I were doing wrong, but I don't understand half the errors the compiler spits back out at me.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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