basic scripting...for the newb

Post » Thu Jun 21, 2012 4:13 am

Ok, so I am a complete newb at scripting. I can world build, and make things look pretty with whats available in the ck. I could prolly manage a small quest. What I do not know how to do is script. Thus my problem below...

I am making a mod that will have a valve (DwePipeValve01) It is an activator device. So when placed in game you can click it and it turns. Obviously this needs to be linked to an item. Is there a way to link it to something (in this case a waterfall) and have that object turn on or off without a script? If so, whats the best way. If not.... :(

Also, does anyone have any good resources for trying to learn scripting (just some basics). I know its a huge learning curve and process (hence why it requires a college degree), but I would still like to start learning.
User avatar
Oceavision
 
Posts: 3414
Joined: Thu May 03, 2007 10:52 am

Post » Wed Jun 20, 2012 10:58 pm

(hence why it requires a college degree)

That's nonsense, you don't need a college degree to script. Yes it's a bit harder than world building, but anyone with a healthy brain and enough motivation can learn scripting.

Check out the Papyrus tutorials, start here:

http://www.creationkit.com/Bethesda_Tutorial_Papyrus_Hello_World
User avatar
Anna Kyselova
 
Posts: 3431
Joined: Sun Apr 01, 2007 9:42 am

Post » Wed Jun 20, 2012 10:45 pm

thanks for the link, i have already looked at that, and it does cover some basics but i was more hoping for some videos, i am a more visual person, hard for me to learn something so complex by just reading a webpage and trying to apply it.
User avatar
Richard
 
Posts: 3371
Joined: Sat Oct 13, 2007 2:50 pm

Post » Thu Jun 21, 2012 4:22 am

I think you won't find many scripting video tutorials, especially because it's relatively complex it's easier to teach through text. You very often need to go back and look something up, and from a video you can't copy/paste examples.

Did you do the tutorial that comes after as well?
User avatar
Alan Cutler
 
Posts: 3163
Joined: Sun Jul 01, 2007 9:59 am

Post » Wed Jun 20, 2012 7:40 pm

yeah, part of the problem for me i think will be finding enough content even though text form to really be able to grasp it. I am having trbl trying to get a new script even made, much less coded.
User avatar
Cathrin Hummel
 
Posts: 3399
Joined: Mon Apr 16, 2007 7:16 pm

Post » Wed Jun 20, 2012 11:56 pm

I was the same way after looking at the hello world tutorial. It is like any programming hello world tut....It doesn't say much. Even though you won't be using everything in all of the tutorials it is a good idea to follow it through start to finish. Start with the basic lvl design and I gaurantee you will pick up some really good info along the way. There is an order to do them as each one relies on knowledge from the previous one. It takes some time but it is well worth it.

There is also some videos listed under "Comunity Tutorials" but they are for paticular tasks mostly, like making a mannequin.
User avatar
anna ley
 
Posts: 3382
Joined: Fri Jul 07, 2006 2:04 am

Post » Wed Jun 20, 2012 9:44 pm

Yeah, ive watched all the tutorial videos (save the ones that have to do with like mesh importing and such). I understand the basic principle of how to make a new script and I am sure with enough searching I could manage to put one together (in fact i think I may have one already)

I just cant figure out HOW to make the PROPER script. IE: would my needed script be an objectreference? if so why cant i select the item I want as my property (in this case a waterfall that ive given a ref ID)? It is stuff like this that is what is so frustrating, there is no info on how to fix errors, or things you dont do right.
User avatar
Neko Jenny
 
Posts: 3409
Joined: Thu Jun 22, 2006 4:29 am

Post » Thu Jun 21, 2012 4:47 am

I'm kinda new myself but maybe I can help with the concept your looking at.

Yes you need an ObjectReference script. It will respond to events related to the object it is attached to. As apposed to an actor script that deals with events as related to an actor.

To set the property to another object just create a new property and be sure it is an ObjectReference Property. Once you do that click "Edit Value". You should see a button that will allow you to select the object in the render window. Double click the object and the property will be set. For instance if you name the property "MyWaterfall" you can then reference it in the script like:


	Event OnActivate(ObjectReference AkActionRef)	   MyWaterfall.Enable()	EndEvent


Hope it helps
User avatar
Alada Vaginah
 
Posts: 3368
Joined: Sun Jun 25, 2006 8:31 pm

Post » Wed Jun 20, 2012 4:40 pm

thanks for the help I have been able to get the first half of the script working, which is to enable the waterfall, to turn it off using the same button/lever/etc again, what would the second half of the script need to look like?


well, it was working, now when i load my cell the valve im using as my activator isnt clickable lol... worked the first time i loaded it now it went poof. I double checked the script and nothing has changed...hmmmmm
User avatar
Michael Russ
 
Posts: 3380
Joined: Thu Jul 05, 2007 3:33 am

Post » Wed Jun 20, 2012 7:43 pm

Try this and see if it works: Notice there is a new Property defined. An Integer to determine if it is On(1) or Off(0). It will begin Off.

Int WaterOn = 0 AutoEvent OnActivate(ObjectReference AkActionRef)  If WaterOn = 0		  	 MyWaterfall.Enable()	 WaterOn = 1  ElseIf WaterOn = 1	 MyWaterFall.Disable()	 WaterOn = 0  EndIfEndEvent
User avatar
leigh stewart
 
Posts: 3415
Joined: Mon Oct 23, 2006 8:59 am

Post » Wed Jun 20, 2012 9:28 pm

Try this and see if it works: Notice there is a new Property defined. An Integer to determine if it is On(1) or Off(0). It will begin Off.

Int WaterOn = 0 Auto

Is not a Property, but a plain variable. It's the right way to go though. Just saying, to avoid any confusion.
User avatar
Robert
 
Posts: 3394
Joined: Sun Sep 02, 2007 5:58 am

Post » Thu Jun 21, 2012 6:59 am

Int WaterOn = 0 Auto

Is not a Property, but a plain variable. It's the right way to go though. Just saying, to avoid any confusion.

DOH!

Right there you are but Papryus lets you set it in the Properties screen so I just called it a property. It can also be declared and have a value set during the event can it not?
User avatar
Taylor Bakos
 
Posts: 3408
Joined: Mon Jan 15, 2007 12:05 am

Post » Thu Jun 21, 2012 6:00 am

got an error when saving that script.
User avatar
mimi_lys
 
Posts: 3514
Joined: Mon Apr 09, 2007 11:17 am

Post » Thu Jun 21, 2012 1:19 am

Without telling me the error you got I know what it is. Try the script below. I corrects my mistakes. It needs to be ==0 instead of =0. My bad. Also remove the "Auto" after the integer declaration.

Int WaterOn = 0Event OnActivate(ObjectReference AkActionRef)  If WaterOn == 0						 MyWaterfall.Enable()		 WaterOn = 1  ElseIf WaterOn == 1		 MyWaterFall.Disable()		 WaterOn = 0  EndIfEndEvent
User avatar
Everardo Montano
 
Posts: 3373
Joined: Mon Dec 03, 2007 4:23 am

Post » Wed Jun 20, 2012 6:34 pm

DOH!

Right there you are but Papryus lets you set it in the Properties screen so I just called it a property. It can also be declared and have a value set during the event can it not?

Regular variables can't be set in the Properties screen. Variables are local and Properties are not, so it's pretty important for new scripters to understand the difference. That's why I said it, not to be a smart ass.
User avatar
D IV
 
Posts: 3406
Joined: Fri Nov 24, 2006 1:32 am

Post » Wed Jun 20, 2012 8:18 pm

No I didn't take it as a smark ass remark and it also clarifies for me as well. Good thing you chimed in. Appreciated.

Kinda used to VB so I always type "If MyVariable = 0" instead of "If MyVariable == 0". I do it every single time :-)
User avatar
Hazel Sian ogden
 
Posts: 3425
Joined: Tue Jul 04, 2006 7:10 am

Post » Wed Jun 20, 2012 9:14 pm

got an error when saving that script.

Did you declare the actual script?

Scriptname waterfallonoff extends ObjectReference conditional

Not sure if "conditional" will work but try it with and without.

Be sure that "waterfallonof" is whatever the name of the script as you saved it.
User avatar
Margarita Diaz
 
Posts: 3511
Joined: Sun Aug 12, 2007 2:01 pm

Post » Wed Jun 20, 2012 10:31 pm

"Conditional" should only be used if you have any variables or auto properties as "conditional" as well. This is only used when you want to expose a variable to the Conditions system with the function GetVMScriptVariable.

FYI, if you want a non-auto Property to be conditional, you should simply mark the variable used to store the value of the Property as "conditional".
User avatar
Strawberry
 
Posts: 3446
Joined: Thu Jul 05, 2007 11:08 am

Post » Wed Jun 20, 2012 5:54 pm

"Conditional" should only be used if you have any variables or auto properties as "conditional" as well. This is only used when you want to expose a variable to the Conditions system with the function GetVMScriptVariable.

FYI, if you want a non-auto Property to be conditional, you should simply mark the variable used to store the value of the Property as "conditional".

You're right.

I had forgotten that the script I am using that I gleaned that from has a bool property that's set to conditional.

I'm still learnin Pap too :)
User avatar
Ashley Tamen
 
Posts: 3477
Joined: Sun Apr 08, 2007 6:17 am

Post » Wed Jun 20, 2012 11:05 pm

I'm still learnin Pap too :smile:

So am I, my first few scripts just happened to be about the techniques discussed in this thread. I too have plenty to learn.
User avatar
Eilidh Brian
 
Posts: 3504
Joined: Mon Jun 19, 2006 10:45 am

Post » Wed Jun 20, 2012 8:07 pm

For a bool like that, try:
Bool bWaterOnEvent OnActivate(ObjectReference AkActionRef)	bWaterOn = !bWaterOn ; Set bool to whatever it is not	If bWaterOn		GetLinkedREF().Enable()	Else		GetLinkedREF().Disable()	EndIfEndEvent
If MyWaterfall is linked, you'll not need a property for it.
User avatar
neil slattery
 
Posts: 3358
Joined: Wed May 16, 2007 4:57 am

Post » Thu Jun 21, 2012 3:31 am

"bWaterOn = !bWaterOn"

I get that this is setting the variable to "NOT"bwateron (true or false)

But does Papyrus use more esoteric boolean stuff?

Like Xor, NAND etc?
User avatar
Kanaoka
 
Posts: 3416
Joined: Fri Jun 16, 2006 2:24 pm

Post » Wed Jun 20, 2012 8:33 pm

Not that I'm aware of, at least not until SKSE. One of SKSE's new Math functions is LogicalXor()...
User avatar
Alexander Lee
 
Posts: 3481
Joined: Sun Nov 04, 2007 9:30 pm

Post » Wed Jun 20, 2012 7:28 pm

Thanks for all the replies! Much appreciated.

One thing I cant figure out is that I placed a Dwemer Valve early on in the process, but now its not clickable/no activator, and any new ones i place arent usable either! Dunno what happened?! (fyi the base dwemer valve script that controls the valve animation is still there and appears to be unchanged, i just cant use it/them)
User avatar
Jade Payton
 
Posts: 3417
Joined: Mon Sep 11, 2006 1:01 pm

Post » Thu Jun 21, 2012 1:33 am

anyone have any ideas on the valve problem? id like to be able to use them as levers dont really fit well with my setting. (script is currently working fine with a lever but still cant get valves to be clickable, which includes newly placed valves with no new scripts attached)
User avatar
SamanthaLove
 
Posts: 3565
Joined: Mon Dec 11, 2006 3:54 am

Next

Return to V - Skyrim