Talk:Main Page

From the Oblivion ConstructionSet Wiki
Revision as of 08:39, 8 April 2006 by imported>Lenko (→‎If problems)
Jump to navigation Jump to search



FaceGen and Oblivion

I was looking around, nice Construction Set btw, but i can't seem to find good help on the FaceGen - Oblivion combination. -This unsigned comment was made by Novus.

The existing game?

Is this wiki a suitable place for discussing bugs/oddities with the engine, or the main Oblivion game? I realise these may not really be editing-related.. If not, is there a wiki that is suitable? Moo 14:47, 25 March 2006 (EST)

This wiki is a reference for The Construction Set and mods. Our official forums are where discussions on engine/game related bugs and quirks should be discussed. Ashileedo 14:27, 26 Mar 2006
UESP Oblivion. You can start the Glitches/Goofs page starting from the link a the bottom. If there's a problem with the engine itself, in regards to modding, that should probably go on the Tes4Mod section. You should look in the corresponding sections of the Morrowindpages for similar pages and follow the lead. (Hmmm... Though I would have thought that glitches in the game engine would be reasonable to put here -- since modders need to work around them while working in CS4.) --Wrye 00:56, 27 March 2006 (EST)
Good point about putting engine issues on here as it could be useful -- My concern is that a list of issues with the game and engine here could turn into a point of contention and attract vandalism. As long as the tone is factual and neutral, should be okay. I would strongly suggest that anything documented must be verified by the contributor themselves or can be based on our readme documentation but not based off forum posts which can be unreliable. We want people to be able to trust what they read is factual and has been verified. Ashileedo 10:28, 27 Mar 2006
I would suggest something like an editors page (might the same as the Help:Editing page). Site policy (what does and doesn't belong, plus standards for addition can be listed there). When listing what doesn't belong (e.g., mod lists, mod ideas(?)), you could also provide links to wikis/sites that are intended for that (and the forums, of course). Also, for page specific formatting and rules, you can put a "Style and Content" section at the top of the talk page (e.g., Uesp Scripting Pitfalls Talk.) --Wrye 11:38, 27 March 2006 (EST)
Looking for something like this: Standards and Policies? It isn't very easy to find at the moment, though.

Sign your contributions

Please, use three (name only) or four (name and date) tildes (~) to sign your contributions on talk pages. Silly 15:26, 25 March 2006 (EST)

Any convention to where we sign - at the start of a message or at the end? Kalniel 10:21, 7 April 2006 (EDT)

Scripting Guide?

Is there any guide out there that has a sort of scripting basic guideline, written for people who haven't done much scripting...

I am trying to make a Lockpick Mold Mod, where an object you use creates more lockpicks by 'melting down Septims as the actual lockpick material, how fitting the tool thieves use to make money is made out of money'.

So I know I have an object, activated, but I have no real clue what I am doing...what I would want to do I guess is somehow fit in a player_buy item script and somehow set up an unlimited source of lockpicks to 'buy'...

Anyone? -This unsigned comment was made by Blakestr. Please sign all comments.

No need to resort to using the buy interface: you could just create the lockpicks directly whenever you use the object. Something like this might work:
 scriptname JTLockpickForgeScript
 
 begin OnActivate
 
 if ( Player.GetItemCount Gold001 >= 6 ) ;Check to see if the player has enough gold
     Player.RemoveItem Gold001 6
     Player.AddItem Lockpick 1
     MessageBox "You smelt down 6 septims to produce one lockpick."
 endif
    
 end
I avoided forcing the player to press a button before activating the forge because that would've complicated the script immensely and made it less useful as an example. I suppose I could start writing a few tutorials, but I'm a much better scripter than a teacher. That should at least give you a good idea of how a script looks and works: first the script's name, then a "block" between begin and end codewords that specifies what will happen and at what time (in this case, OnActivate means the code will be processed whenever the player "activates" the object). --JT 14:39, 31 March 2006 (EST)
Remember to sign your comments!  
Use ~~~ to sign with your username. E.g., JT
Use ~~~~ to sign with your username and the current date. E.g., JT 14:38, 31 March 2006 (EST)


More Tutorials Please

I loved the create a dungeon tutorial, I wish there were more intermediate tutorials. I've been messing around with the editor and but learning on my own is slow and cumbersome. Do any other good editing resources exist? FViral 17:42, 26 March 2006 (EST)

I also thought that the "My First Dungeon" tutorial was excellent, but we need to expand on it and add more. One on basic quests, scripting, havok, etc would be great. I already have a fairly cool dungeon laid out, but I am not sure where to go with the NPC quests for it. Also, does anyone know how to include havok'd rocks in a project?

--Void Main() 00:52, 27 March 2006 (EST)

For my part, I'd like a tutorial on creating shopkeepers - I figure just about everyone is going to be creating dungeons, so I'd play around with something different. I'd also really like if, when Bethesda releases everything necessary for full creation of armor/clothing, someone could post a MAX file of something generic with all the settings correct so I could open it up and look at it. An ideal situation would be Bethesda actually posting one or more of the MAX files used to create the master file...

Aesirgard 12:35, 7 April 2006 (EDT)

I plan on releasing a tutorial explaining how I did my mod when it's finished. It'll cover some scripting, dialogue options, and NPC creation. Sockmonkeh 12:58, 7 April 2006 (EDT)

Offline Help

Is there a way to download this Wiki or offer it for download so that those without internet access 24/7 can still get help when modding, if it was html a simple downloader would work, but its php and I can not find one suited for it.

Thanks StaticNation 4:55 AM 28 March 2006 (CST)

Well, the problem with that is that a Wiki is always changing, and at this point the TESCSWiki is far from complete. --JT 14:07, 31 March 2006 (EST)

Bethesda Editors?

I'd really like to see an official page that lists all the official Bethesda editors. The page should be locked. As TESIV ages, the developers will have less and less input on the CS. When comparing revisions of documents on here, it would be nice to know that certain users were official Bethesda authors, versus someone adding into their User page Bethesda level designer or such, even if they aren't. An official locked page would remedy this problem (and it will happen, it always does on larger Wikis). Daego 11:57, 28 March 2006 (EST)

Admins list

--Kkuhlmann 13:32, 28 March 2006 (EST): List of admins (this is linked from the Standards and Policies page, which might be what someone else was asking about).

what's the difference between a sysop and Bearucrat? (sp?) Stormscape
That's wiki admin stuff. Bureaucrats have the ability to raise other users to sysops. See MediaWiki for more info. --Wrye 19:01, 29 March 2006 (EST)

NPCs

Anyone know how to add equipment to a new NPC? i dont see where i can and armor and weapons to these npcs, help appreciated. -This unsigned comment was made by Jpbmerlin

Hi, Just drag and drop items in their inventory window, they will auto equip, and in options u may state them to keep em unequipped.

Cheers...

Custom Models

Elder Scrolls is based on the Gamebryo engine which uses the .NIF and .KF file formats for statics and animations. Even though the developers for Oblivion haven't released an exporter for later versions of 3ds Max (there's one for 4 but everyone I know is at least using 7 if not 8) modders looking to use custom content can, for the time being, use Civilization 4's Max plugins to get the job done.

A couple of notes on the process: you don't need to go through all the documentation 's tutorials, since most of the features they discribe don't work properly with Oblivion (I'm still amazed it works at all).

Apply a Standard Max material to your object. For the time being we only get boring diffuse with no shaders, but at least it's a start. The texture file can be stored anywhere since it's included in the .NIF on export.

CIV 4 NIF Exporter Settings

Once that's done simply File->Export the model as a CivilizationIV (*.NIF) file to the /Data/Meshes/YOUR_PLUGIN directory of Oblivion. Uncheck "Lights" and "Cameras" and under Textures check "Include in main NIF". Open up the Construction Set and create a new static object using your new NIF file.

If I run across any more functionality that can be pulled over I'll post it here. GrantM 6:25, 30 March 2006 (MST)

[Edit Kahr606] Althoughy you can export meshes to Oblivion, they will not have the functionality that Oblivion objects do. This is because the Civilization IV exporter, obviously, isn't compatible with Oblivion's Havok physics engine, and therefor cannot export any physics collision data. To see this, go into the Oblivion Editor and open an area in the render window. If you enable the Havok Preview, you will see that any interactive objects have some sort of yellow collision outline around them. Any objects that you import to the game will not have this. This means that, were you to create a sword mesh for the game, you could equip the sword and use it. You could pick the sword up from a container or buy it from a merchant. But, if you were to drop the sword on the ground and try to pick it up again, you would not be able to do so. So until someone creates a plugin that properly works with Oblivion's NIF format, all of your meshes will be relatively static.[End Edit]

Adding new pages?

Can we add new pages/categories/etc to the Wiki? I haven't figured out how, but in particular I think that .ini mods and .xml mods need sections for them, since they are probably the most popular mods right now, and are going to continue to be important. They're also something that the average person would be very interested in tweaking for their own preferences, and so this Wiki definitely ought to have sections for them. Does anyone know if we can add them, and if so, how? And if not, why not? And if not, can Beth do it for us, please?

--Kkuhlmann 16:08, 30 March 2006 (EST)Anyone can add a new page by simply typing the URL, and editing the blank page that comes up. You'll need to put a Category:XXX link at the bottom of new pages if you want anyone to find them (preferred), or link them directly from another page (usually not preferred).

.DDS file settings.

I was wondering what settings do the DDS files use. Like 32 or 16 bit?, RGP or ARGB?; stuff like that.

How about adding a "Eye and hair texture tutorial". That would help me a lot.

// AKH|Arazand


DDS files are compressed textures used for DirectX 3D rendering; they are 32-bit with transparency, as well as mip-mapped (meaning they have reduced-size versions of the full image stored inside the file, since rendering a high-resolution texture at a long distance is a waste when the detail can't be seen by the player anyway). Instead of working directly with the file format, however, you can easily just use a DDS conversion tool on some other format (most likely TGA) to create your DDS files. Google is everyone's friend. =) --JT 16:54, 31 March 2006 (EST)


Thanks a lot. So that means I have to use the alpha layer while working on it? How can I make this mip-mapping work?Through google before I posted the original post i found NVIDIA's plug-in for Photoshop I tried to use that but every time I tried to load the texture in CS it said the image was invalid. But I'll try a converting tool insted. Thanks for the info and tips! --AKH Arazand

Adding potentially obvious instructions?

I was flipping through some of the character settings in the editor and was looking at adding a Birthsign and couldn't figure out how I was supposed to get spells in the list. After a minute or two, it occurred to me to go look through the objects list instead of magic efects. Then you just drag and drop a spell from there. Arguably, it didn't take me long and would be completely obvious to some people. So my question is whether or not adding these kinds of potentially obvious instructions would be frowned upon for cluttering up the Wiki or some such.

If not, should they be contained on directly on that page or a page linked under it? Gunslinger 19:12, 31 March 2006 (EST)

Lacking useful functions

I've been browsing through the list of functions, and I'm surprised that some obvious ones seem to be missing. One thing is, there are no alchemy functions. Another, more surprising is that there are no angle/radius positioning functions, apart from PlaceAtMe, which creates a new instance.

You can get a heading and distance to something, but you can't position objects by them, so you can't e.g. move an existing object to be in front of the player or another actor. There also seems to be no way to tell actors to simply move a distance ahead. It seems that the only way that this can be done now is using trigonometry, but of course, there are no trigonometry functions.

Is there a wishlist for the next version/expansion? EagleEye 09:50, 1 April 2006 (EST)

Square root also seems to be gone :(EagleEye
UESP Wiki has some math approximations: Math Functions. Sqrt not included since they're for Morrowind, which has sqrt. --Wrye 00:38, 2 April 2006 (EST)
--Kkuhlmann 09:43, 4 April 2006 (EDT): There are a number of position functions: SetAngle, SetPos, PositionCell, PositionWorld. Using these on actors, however, can lead to unexpected results (they may still think they are somewhere else). Actors should be controlled using packages.
Jaks 13:50, 4 April 2006 (EDT): Not sure thats always possible. Packages, at least in this early stage of my learning curve, seem VERY limiting. Its difficult to integrate them with in with scripts and their needed timings for intricate manueverings of NPCs. I tend to think of packages as daily routines for the AI to go about their business but quests and player interaction, in my eyes, should use scripts to override those routines. On the other hand, the script API does provide the ability to add and remove packages on the fly, so maybe a combination (much like the recently released HorseCommands mod does) is the better choice. In the end though, I do not think packages provide for the level of detail this request is asking for.
--Kkuhlmann 16:50, 7 April 2006 (EDT): Well, we managed to put together a number of rather intricate scenes using the same tools you have available to you -- charactergen, for example. Every staged scene in the main quest. Do I wish we had better tools? Sure. But I think you need to look at some of the scripts and NPC packages used in charactergen (for example) before you decide that packages are "very limiting".

How do I place new objects in an exterior cell ?

I have been playing around with the CS, and have no problem in editing interiors, but I cant seem to change exterior cells. also I cant see any objects outside the cities. Does anyone know what I´m doing wrong ? --User:Zabbath

Cities are separate worldspaces. Instead of Tamriel, you can select things like AnvilCastleWorld in the area drop-down list. Exterior cells are located in "Tamriel". That help? Daego 16:11, 2 April 2006 (EDT)

Ahhh... That´s done it, boy do I feel stupit now. We are building a fighting force of extra-ordinary magnitude, you have our gratitude.User:Zabbath 13:03, 2 April 2006 (GMT)

Known Issues

Doppelganger 18:58, 3 April 2006 (EDT): "Data race" was in fact undocumented modifiers on the ModActorValue function, now documented by one of the people in the know. The difficulty, however, in getting this information was altogether too much...

/signed, we need an area to report issues and verify them as known. Nowhere does it say that the script compiler/editor will silently fail to compile a script with mismatching parens () .. I just spent an hour looking for a syntax error, it turned out to be a missing open paren, the script editor silently failed with no warning when compiling the script - it just refused to save my changes. I'd like to save other people this headache. --Halo112358 22:09, 2 April 2006 (EDT)

--Kkuhlmann 09:49, 4 April 2006 (EDT): Re: silently failing -- The compiler will throw up a warning over any compile error. Is it possible that you already clicked "Yes to All" to a previous warning (which would turn off all warnings for your current session)? Check the EditorWarnings.txt in the editor's folder -- you'll see the warnings there even if you turned off the popup.

--Gerrie Hi, dont know where else i should put this: Error Message: "Warning: Unable to complete operation due to failure removing previous tempfile remains. Continue playing? "Yes to all" will disable warnings this session." This means some application is still using your plugin file and the construction set fails to save your new version. Be careful not to press "Yes", as all your following saves will get lost with no error message. To solve this: Close your programs and reboot, when you get the errormessage for the first time. Does anybody know a better workaround, so you dont lose your newest save?

Cyrodiil Borders

Is there a way to turn off the invisible borders around Cyrodiil? They kind of put a huge crimp in landscaping the cells outside of Cyrodiil unless you use a teleport device to get you there.

My guess is that they are simply invisible objects (invisible wall from Morrowind anyone?) so just go there to that cell and delete them. Stormscape 15:10, 3 April 2006 (EDT)
Open up the Region Editor, select Tamriel, find the CyrodilBorderRegion, and uncheck the Border Region option. Believe that will do it. --Urizen 12:28, 4 April 2006 (EDT)
Although, on second thought, it would probably be a better idea to create a new region for the area you want to use, and just change the relevant cells from CyrodilBorderRegion to your new region id.--Urizen 12:32, 4 April 2006 (EDT)
The region editor did the trick! Thanks very much for your help. Ten10ths 4:46 5 April 2006 (EDT)

Reset Cell

Is there a way to reset a cell using script other than waiting 3 days for it to autoreset? --IMP 11:17, 3 April 2006

Blade & Blunt

My brother and I want to make a mod that would make Blade and Blunt weapons act differently. Unfortunately, I can see no scripting functions which would aid in this and although I've checked the settings page a couple times, it seems that any useful variables affect both Blade and Blunt. The only way I can think of at the moment would be to make enchantments and apply it to every Blade and Blunt weapon in the game, which would cause many other problems in the process.

Is there any way around this? Or if not, would it be possible to update the CS to advance its functionality?

--ZantarV

Settings Documentation

The settings page is home to many variables useful for tweaking gameplay easily. However, many of these variables have cryptic names and/or implementation. Would it be possible for developers to take some time detailing some of these setting and their affect on gameplay?

--ZantarV

Scripting Question

Hey, I didn't see any discussion or question page, so I guess I can ask this here. I want to make it so if the player walks into a very large area, they will be given the option to go to a seperate worldspace and in that worldspace be at the exact same coordinates. Is it possible to set variables to the player's X, Y, and Z coordinates, load a seperate worldspace, and set the player's coordinates to those variables? If this is not possible, is it possible to do so over a very large area, like not with markers and things? Sload 18:25, 3 April 2006 (EDT)

Inventory Reference

I've been looking all over the place but I can't seem to find any way to reference what is in the player's inventory without knowing the specific refs to begin with. As a compromise, is there a way to return the ref for what the player has equiped or is wielding? Skrath 06:06, 4 April 2006 (EDT)

Throwing items dealing damage. How?

I friend of mine have been thinking about a new spell or skill or just something that could be used to enhance the game. Like in HL2 they have the gravgun which enable you to throw items at your enemies at an incredible rate; dealing a lot of damage. And now he got this idea why not have some kind effect in Oblivion?

What I mean is being able to "throw" or "shot" items at the enemy and deal damage. How can you make that posible? Do I have to start rewriting the havok script or is there premade options that enable any item to deal damage on creatures and characters when thrown? If i have to work with scripting can I copy the effect in HL2 havok system or can I use the same script that arrows use while shooting a bow or crossbow?

--AKH|Arazand

Since traps (using physics) cause damage this probably shouldnt be a problem.Skjalg

That is true but, I've already tried that it didn't work. The items simply fell to the ground dealing no damage what so ever. And to be able to use the trap function when ever and where ever by player characters this is my problem. Since throwing items deal no damage on NPC's and only traps do how can I make players able to turn items into traps with in the game it self making it them able to deal damage that way, anywhere at anytime.
--AKH|Arazand

Can we get a tutorial section on the main page?

I forsee a lot of tutorials for this and that being written, would be nice to have once place with them all listed. Sockmonkeh 12:27, 4 April 2006 (EDT)

--Kkuhlmann 13:33, 4 April 2006 (EDT): Good idea. Done. I know there are more tutorial pages out there (at least some stubbed in ones), so please add them to the Category:Tutorials if you know of them.

I love how supportive of the mod community you guys are. Sockmonkeh 14:34, 4 April 2006 (EDT)

Bethesda and mod developers releasing mods

Does Bethesda have a system in place for mod devs to launch a mod, and get payment for it (with security in place), as Bethesda is doing with their own mods? Just like Valve has for its huge mod community with HL/HL2 over Steam? Skjalg 14:40, 4 April 2006 (EDT)

I doubt it. If you read the license agreement, any mods created using the construction set are property of Bethesda. BCampbell 12:59, 5 April 2006 (EDT)

Site skin does not display properly on Mac Safari (10.4.5)

Hello all,

This site does not display properly on Mac OS X (PowerPC) 10.4.5 Safari web browser.

Here's a cropped screenshot:

Note that the sidebar (Navigation, Toolbox, Search, Personal Tools) seems to overdraw the rest of the page.

Thanks!

Callie 18:08, 4 April 2006 (EDT)

It's a problem with the javascript, apparently. I tried to do some troubleshooting on it thinking it was a stylesheet bug. I wasn't having problems with a local version, so I turned off javascript (using Shiira, it renders with Apple's WebKit) and it worked fine. Alternatively, you can use the other skin. Gunslinger 12:15, 5 April 2006 (EDT)

Merging Plugins

Have you published any program which you can use to merge the different plugins you have? Isnt this necessary for a team of people who want to work on a mod together? Gerrie 22:49, 4 April 2006 (EDT)

Tes4's introduction of FormIds, while greatly improving mod stability, do so at a high price -- the ability to (easily) merge mods -- and even to communicate between mods. (E.g., two esps can no longer communicate through a shared global.) More info: Uesp: FormId and Uesp: Mod Integration. --Wrye 23:50, 6 April 2006 (EDT)
Concerning communication between mods through global variables I have posted an idea for a potential workaround on Wrye's thread on the TESCS forum. --xebeth 06:19, 8 April 2006 (EDT)

Twitching the soulgems

Hi everyone,

I was looking to change the enchantements created by the enchantment center, I've already boosted up the charge of the grand soulgem, the charge of a grand soul, I need yet to modify the enchantement automatically created. Nothing better than an example :

I have a grand soulgem charged at 2000 (instead of 1600), a grand soul charged at 170 (instead of 85) and i still can't create a fortify intelligence greater than 10. I've tryed changing the enchantement called EnAppFortifyIntelligenceGrand but that didn't work.

And that's where I turn to you guys...

Dj23


Island house

Hi im working on my small island house/dungeon mod and since the island is so far out to sea i dont want to keep casting waterwalk or try to script a ring to tele me back and forward i was wondering how to create a fast travel point if anyone could help me on this it would sure be nice of you

Cleaning up a plug-in

Seems to me there is no way to delete any of the objects you create. I've made a lot of stuff for my mod that isn't used anymore and I would like to get rid of it. Also, I somehow accidently modified some of the horses, so now my mod is not compatible with Call Steed + Saddlebags. How can I fix this?

-- Answer -- Open TES:CS, then when you're selecting your mod in the data file list, click details. Go and find the reference that you no longer want to be associated with your mod. Select it, and press delete. Accept the box saying it will be ignored. Now go into your mod, make any change to any aspect so you can save it, then save. The Ignored reference will no longer be part of your mod. -Tandem


JBurgess 23:01, 6 April 2006 (EDT) You might want to add this to the Solutions category.

Audio Settings for Dialogue Tutorial Video

I have a video tutorial made for correctly setting your .wav and .mp3 files to work with TES:CS, and how to link that to a character/dialogue route. The link is http://feinam.20megsfree.com/Oblivion/Misc/DiagTut.zip I just don't know really where to put it in this wiki. Could someone please add it for me? 3 ~ -Tandem

JBurgess 22:55, 6 April 2006 (EDT) Try the Tutorials Category on the main page - I haven't looked at your work yet but it sounds useful, and more people will find it there.

I went ahead and created a page for you in the Tutorials section. I would also recommend uploading your file to this Wiki and linking it from here. --Brainspackle 04:00, 8 April 2006 (EDT)

A not animated moving gate

I've been trying to make a gate, that would move when activated. So I've come across a problem. My question is, can "MoveTo" be used in this manner:

mySelf.MoveTo mySelf, 1, 0, 0

This should move the activator(the gate) 1 point into the positive direction of vector X. But it doesn't. Any clues, anyone?

--Lenko 09:01, 7 April 2006 (EDT)

Ok I've tried alot, and since nothing worked I presume that static objects/activators cannot be moved with a script. However the player and most likely other actors can be moved with this command. (Not sure about the items)

--Lenko 07:39, 8 April 2006 (EDT)

Skill checking script

I'd like to create a script that triggers some actions when a player casts a certain spell depending on that players "something" skill level. I have tried some things but none seemed to work, any suggestions? Maybe I haven't been using the good script type so tell me what you think... Thank you in advance.

Ex: When a player would cast a custom made power-type spell there would be a text message depending on his sneak skill level and wouldn't be able to have the spell take effect if his skill level is below 95.

   Hawkes


If problems

Each time a put an if condition in a script, CS tells me there's an "End without matching Beging" error, I even copy/pasted parts from other scripts to make sure syntax was O.K. Why?

Here's one of my scripts I have tried to create in wich CS sees an error (It takes part when the player opens a book) :

      ScriptName EOLreinbook

      short read
  
      begin onActivate

	      if read == 0
		      activate
 		      set read to 1
		      ;add the spell zzreinsab in player's spell list
	      else
		      activate
	      end if
	
      end
   Hawkes


try "endif" as one word ;-) Mrflippy 04:03, 8 April 2006 (EDT)


Lockable Container/Door Tutorial

Ok so lets make a container or a door that can be unlocked and locked back with a key.

First we need to make a key, give it a unique ID(lets say "SecretChestKey"), give it a name, select a NIF file and an icon. We won't need any script for the key.

Then lets make a container. Again give it a ID(in my case "SecretChest"), a name, a NIF and select open and close sounds. Then put in whatever you want to have in this chest. If you want to do this for a door do the same(ID,name,NIF and sounds). Leave the script field empty for now.

Then put the container/door into the world, and doubleclick on it. Go under the lock tab, and select "Locked", then under "Level" choose "Needs a key", and under "Key" select the key you made before(in my case "SecretChestKey").

Ok now we have to write a script:


;First the name of the script
scn TCSecretChestScript

;Then a reference to the container itself
ref mySelf

;And a short variable
short button

;Ok, when we activate the chest,
Begin OnActivate

;the program checks if it is the player that activated it
if IsActionRef player == 1

        ;Reference mySelf is set to the container
        set mySelf to getSelf

        ;Here the fun begins,.. If the container is locked and the player has 
        ; the key... (GetItemCount returns the number of items(in our case keys) the
        ; player has, so if the number is greater than 0 that means the player has 
        : the key to the container)
	if mySelf.GetLocked ==1 && player.GetItemCount SecretChestKey > 0

                ;then unlock the container
		mySelf.UnLock

                ;and give a message that the chest has been unlocked
		message " You unlock the chest with the key."

                ;and then open the chest, and let the player see what's inside
		mySelf.Activate player

        ;and if this is not the case, check if the chest is not locked 
        ; and the player has the key
	elseif mySelf.GetLocked == 0 && player.GetItemCount SecretChestKey > 0

                ;then ask the player if it would like to open the container
                ; or lock it (Function GetButtonPressed is later used to return 
                ; the number of the button pressed by the player)
		messagebox "Would you like to open or lock the chest?", "Open", "Lock", "Cancel"
        
        ;But if the chest is locked and the player doesn't have a key,
	elseif mySelf.GetLocked == 1 && player.GetItemCount SecretChestKey == 0
                
                ;then tell him he needs a key to unlock
		message " You need a key to unlock this chest."
	
        ;And if the chest is unlocked and the player has the key,
        else

                ;then open the chest
   		mySelf.Activate player
	endif
endif
end


;and then in gamemode
begin gamemode

        ;get the number of the choice from the previous messagebox and store it in a variable "button"
	set button to getbuttonpressed

        ;if the button has been pressed, then check what was it
	if button > -1

                ;if it was "Open"
		if button == 0

                        ;then open the chest
			mySelf.Activate player

                ;if it was "Lock"
		elseif button == 1

                        ;then lock the chest with 100(that means, that it needs a key)
			mySelf.Lock 100

                        ;and tell the player it has been locked
			message " You lock the chest with a key."

                ;if button "Cancel" has been pressed, then
		elseif button == 2

		        ;do nothing

		endif
	endif
end


If you are doing this for the door, change all the "chest" in the messages with "door", and it should work just fine.

If you want a message box to appear when you open a chest, instead of just a message,.. Then just change the "message" with "messagebox".

And now that you have the script. Open the container you made earlier(from the object window, not the one in the world), and select this script for it.

And thats it.

There is also another simpler way of doing this. It would work differently, that when you would first activate the chest it would unlock itself and open. And when you would activate it the next time it would lock itself. If this is the case just do the following:

1. Delete this line:

short button

2. Change this line:

messagebox "Would you like to open or lock the chest?", "Open", "Lock", "Cancel"
  With these:
mySelf.Lock 100
message " You lock the chest with a key."

3. Delete these 2 lines:

else
     mySelf.Activate player

4. And finally delete everything after this line(including this one):

begin gamemode
.
.
.


So that's it, it worked for me, it should work for you. If you have any questions ask them here. (or email me: matejlenarcic@hotmail.com)

If you spot an error please post here.

And if there is a better place when this could be put, please let me know.


--Lenko 08:39, 8 April 2006 (EDT)