Jump to content

Scripting


Renarion

Recommended Posts

I'm a new modder. Only published 1 mod so far (XD Shadow Grove), which is really just basic techniques chained together in a good way :biggrin:. But enough of that.

 

What really presents a problem for me is scripting. To create a few script lines for the quest in my first mod I simply copy/pasted the lines from other quests and adjusted them to fit my needs. For an example, to make the quest finish when the character entered a certain interior I used a few lines of the Frostcrag Spire quest's script (Wizard's Tower) - the part when you enter the tower for the firts time. There the mesage box activates when the player comes into a certain radius from the book Frostcrag Memoirs.

 

And this is how I created my first script :closedeyes:. But soon I realized that I won't be able to repeat this process forever, as I'll need scripting commands not easily found or I'll have problems with scripts not working properly for apparently no good reason. I'll ask modders with experience to help me through this topic :thanks:.

_______________________________________________________________________________

 

For a start, I need a script which will activate the first step of the quest when the player enters a city. I was unsure how to do this, so I wrote something like "if (Player.GetDistance)" command, and I connected it to a map marker (red cross) found near the main gates of Anvil, followed by a "<= 1000" to specify the radius. It didn't work, which confused me because this is exactly how I've done the script in my first mod. Can someone help, please? I don't have my original script at hand, but I will post it here in a few days.

 

Also, I'll need much more help understanding scripting and I haven't found exactly an abundance of useful information. Links to good hints and good tutorials would be great, if not a direct solution for my troubles from experienced modders on TES Nexus.

Link to comment
Share on other sites

For your script you can try: (if Player.GetInWorldspace XXX == 1). Where XXX is the name of the worldspace, like "BravilWorld" or "BrumaWorld", etc. All cities have their own separate world spaces (or two) so they don't bog the game down with too much processing.

 

(The parenthesis aren't strictly necessary, but most moders use them because that is what they are used to from other languages).

 

You can also use a similar GetInCell XXX, but this only works with Interior Cells (One command for interior, another for exterior).

 

For help with scripting: http://cs.elderscrolls.com/constwiki/index.php/Main_Page

Link to comment
Share on other sites

For your script you can try: (if Player.GetInWorldspace XXX == 1). Where XXX is the name of the worldspace, like "BravilWorld" or "BrumaWorld", etc.

Just keep in mind that this if block will only run if the player's in the Anvil worldspace, it won't run if the player's in an interior in Anvil. Dummy cells can be used as a workaround:

If ( Player.GetInCell Anvil == 1 )
; Do stuff
EndIf

 

It's explained briefly in the GetInCell article on the CS Wiki.

Link to comment
Share on other sites

  • 2 weeks later...

Alright, successfully done. The GetInWorldSpace command works as it should. At first the quest didn't activate when I entered Anvil, but soon I realized I didn't check the field "Begin on game start" in the quest panel. Stupid :wallbash:.

 

I now have another issue to deal with. Yeah, just another in a parade of constant interruptions that are trying to destroy my greatest work! I've briefly browsed through the forum but didn't find a suitable topic. I'll just post it here, although it's not really about scripting :thumbsup:

 

______________________________________________________________

 

I have created an Actor to serve as a new merchant. I have already fully created the shop as well as prepared the "shop chest" which I conveniently placed a bit outside the structural geometry (I studied the merchant Rohssan in A Fighting Chance). I have tried to adjust my merchant to Rohssan's options, but there is of course a problem :rolleyes:

 

I have already figured out that the items which the merchant sells are located in a chest. But when I go under the tab "Merchant Container".... The Select Reference button doesn't let me select my chest. When I try to do it manually, by selecting the shop cell from the drop-down menu, the lower menu only displays "NONE". Somehow my chest isn't recognized or something!

 

Rohssan's chest, on the other hand, works perfectly! Damn!

 

 

 

Probably I've missed some small but obviously important detail. Please help! I do not have internet access at home so consulting CS Wiki isn't so easy for me, as it takes a lot of time finding the answers. But still, my issues are mostly precise enough to ask for help here on the forum. So don't point me to the WIKI, rather give me direct help here.

 

I will be back online in a few days, and would appreciate an answer :thanks: .

Link to comment
Share on other sites

A very minor, but obviously important detail. Your shop chest needs to be a persistant reference. It does not need a name, but it is usually easier if you give the chest a unique name. When you give names to persistant objects, avoid starting the name with a number.
Link to comment
Share on other sites

Best advice I can give would be to take the time and learn what most of those error messages mean when you try to save. The first mistake people often make is in thinking that that error message doesn't mean anything useful, or is in some strange indecipherable language. Often, just looking at what line is being reported as being an error, you can often know what you need to fix.

 

If you don't have a reliable internet connection, I strongly recommend downloading

http://www.tesnexus.com/downloads/file.php?id=19136

 

It's a backup of the wiki site and contains a full listing of scripting functions and help pages. It requires a bit of space, and may not have all the images working, but it's a small price to pay.

 

Once you get past the initial learning curve related to using variables, references, and how scripts run, most of scripting is just a matter of piecing together functions that do what you are wanting to do. A common approach is to figure out the end result that you want, and work backward thinking about how that result can be achieved, who you want it to apply to, and under what conditions. Although OBSE can accomplish much more than vanilla scripting, when you're just starting out and learning the basics, it's usually best to stick to the vanilla functions and only use OBSE in those cases where nothing else works.

Link to comment
Share on other sites

Thanks people :thanks:

I will be sure to download the backup using the link provided, as well as examine it closely.

 

Like I said, my knowledge about modding comes 90% from dissecting other mods and examining them. When I do have a problem its always a specific one, it rarely happens that I haven't the faintest idea on how to do something.

 

Good thing there's such a well organized forum with such devoted members to talk to :yes:

 

 

 

I will continue to do my best to finish my newest project and distribute it across TES Nexus.

Link to comment
Share on other sites

  • 3 months later...

Seems I got myself into some trouble again.

 

Here's the situation. Imagine a dungeon hallway. Somewhere along that hallway there is a portcullis. Beside it is a lever that controls it. So far so good, eh? I copied the script for the lever from one of the default dungeon levers, checked it a bit and concluded it was pretty much generalized (using myRef and myParentRef). I've set the child/parent link and it was working well until I discovered that it was possible to simply activate the portcullis by clicking on it.

 

What happened to "This door is activated elsewhere."? Then I learned that the portcullis too needs a script attached to it, so I copied one from the default dungeon portcullis script. As a result, the portcullis is now permanently stuck in its closed state, and while the lever does indeed play the sliding animation it does not control the gate.

 

On the other hand, I got the "This door is activated elsewhere." message. Only now that's small comfort.

 

I've studied both scripts carefully but couldn't find what's wrong. I also tried removing some parts of code I deemed redundant, to no effect. I'm completely clueless now and could really use some help :rolleyes:

Link to comment
Share on other sites

  • Recently Browsing   0 members

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