SonAnima Posted January 16 Share Posted January 16 So Im currently learning HTML, CSS, and JavaScript and what Im wondering is will any of this knowledge translate over to Papyrus? I know that Papyrus is its own language but Im just curious if there is any similarities in popular programming languages and Papyrus. Link to comment Share on other sites More sharing options...
Qrsr Posted January 16 Share Posted January 16 Have a look here:https://falloutck.uesp.net/wiki/Papyrus Link to comment Share on other sites More sharing options...
SonAnima Posted January 18 Author Share Posted January 18 Thanks for the link. I took a look at the page and got confused so fast lol. I had to pull up a youtube video to see how someone made a script. Seems like many of the functions like arrays, IF/ELSE statements, and making functions behave just like those in Javascript but thats the only similarities I seen. I didnt see anything that looked like HTML (except in animation files) so I just gotta learn the weird quirks of Papyrus which some of them seem rather redundant for no reason. Link to comment Share on other sites More sharing options...
Zorkaz Posted January 18 Share Posted January 18 I'd suggest you start out with a simple "Enable/Disable" script and work your way up. Link to comment Share on other sites More sharing options...
niston Posted Wednesday at 12:50 PM Share Posted Wednesday at 12:50 PM Hi and welcome to Papyrus development! The nearest "HTML equivalent" would be plugin records. For example, assume you want to display a message to the user from your script - In effect a classic "Hello World" application. While there is Debug.Notification, where you could do: Debug.Notification("Hello World!") But. this only works on PC! Why? Because it uses the Debug script, which is not available on console. The "proper" way to do this is therefore with a Message record in a plugin: Once defined, you then need to make the record accessible to your script. This can be done in two ways: 1) A script property of type Message 2) By using Game.GetFormFromFile() For simplicity, we use the property approach. Our script might look like this then: Scriptname Test:MyTestScript extends ObjectReference Message Property tst_HelloMessage Auto Const Mandatory Event OnActivate(ObjectReference activatedBy) tst_HelloMessage.Show() EndEvent We have the Scriptname line defining the namespace and the name of the script. It also defines what other script our script extends (inherits, or derives from). In this case, our script is in the Test namespace. The namespace corresponds to a folder in your Scripts\Source\User folder. Inside that folder is the script file and it must be named MyTestScript.psc - If the filename does not correspond to the name given by Scriptname, the Papyrus compiler will complain and refuse to compile the script. Furthermore, our script derives from ObjectReference script. This means that our script inherits all the methods and properties of the ObjectReference script, and that we'll be able to attach the script to any ObjectReference. But, more on attaching scripts later. Next, we have said Message property. I called it tst_HelloMessage, so it corresponds with the name of the record in the plugin. This makes our life easier as it allows CK to auto-fill the script property at the click of a button, instead of us manually having to find and assign the Message record to the Message property with a drop down box. The property is furthermore being declared Auto Const Mandatory. The Auto means you don't have to write setter/getter methods for the property, nor define a backing variable - The compiler will do it for you. The Const means two things: 1) The property value cannot be changed at runtime (our script can't assign a different message to it, or set it to none) and, crucially, 2) the property value will not bake into our saves. Finally, Mandatory will cause CK to prompt us to fill out the property when we attach the script. As you can see, there is an event handler for OnActivate event at last. This event is available to our script because we derive the script from ObjectReference (extends ObjectReference) and OnActivate is an event handler on ObjectReference script. Our script therefore overrides the base event handler in ObjectReference (which is declared native and has no method body). The game will invoke this event handler on any script that is attached to an ObjectReference, whenever the reference is activated in game. Our particular script with it's OnActivate event handler will usually attach to a reference of type Activator, but it could work with some other types as well. In any case, the event handler references the tst_HelloMessage property and invokes the Show() method on it. This will cause the Message record referenced by the property to be displayed on screen, in game. Compile the script. Now, to exist in the game world, a script basically needs to be attached to something. In this case, we'll use an Activator so that player may... activate it. Heh. I copied an existing Activator, named it tst_TestButton and attached our script to it: Remember the script property needs assignment though (Mandatory), so CK prompts us to fill it when attaching the script: Now, because we named the Message property the same as the actual Message record, we can just click the "Auto-Fill All" button and CK will fill the property for us: See, the tst_HelloMessage record has been automatically assigned to our property. So now that we've defined an Activator making use of our little script, it is time to place this Activator into the game world. This is easiest to do in CK, where we can load any worldspace (or interior) cell and simply drag and drop the Activator into the render window. We'll put this one in Sanctuary, so that we may easily find it: And now is time to save our plugin, activate it in the load order and test in game: Lo and behold: It just works! Hope you'll find this useful to get a head start into Papyrus development. Papyrus is surprisingly powerful for a "toy" language, even though the development process can be a bit contrived. I mean, all the above does is display a fixed string in game. And it gets much more complicated if the string shouldn't be fixed, but assembled at runtime - But that's a topic for another post. Cheers and happy gaming modding! 2 Link to comment Share on other sites More sharing options...
AndalayBay Posted Thursday at 12:53 AM Share Posted Thursday at 12:53 AM @nistonwould you consider converting that into a wiki article here on Nexus? The CK wiki has been down for almost two years now. I know the UESP has a copy of the Skyrim CK wiki, but I find it hard to navigate. I appreciate this little article as a starting point. I'm a java and C# programmer, but find Papyrus ridiculous to work with. Link to comment Share on other sites More sharing options...
niston Posted Thursday at 01:54 AM Share Posted Thursday at 01:54 AM There is a wiki on nexus? Link to comment Share on other sites More sharing options...
AndalayBay Posted Thursday at 09:28 AM Share Posted Thursday at 09:28 AM ROFL While I strongly suspect that you're pulling my leg, yes there is a wiki which has a variety of articles and tutorials. The UESP will also host other wikis. They picked up the wikis I was hosting when I shut things down. They are focused on Elder Scrolls games though. Link to comment Share on other sites More sharing options...
niston Posted Thursday at 10:35 AM Share Posted Thursday at 10:35 AM No, after 5+ years of modding I was genuinely unaware that nexus has a wiki. LOL. Thanks. I will probably add the article. Link to comment Share on other sites More sharing options...
niston Posted Friday at 03:16 AM Share Posted Friday at 03:16 AM I made a page on the new Wiki. Apparently there's two of them but only the new one works. I don't have the slightest idea how to publish the page. Link to comment Share on other sites More sharing options...
Recommended Posts