UESP Forums

Discuss the uesp.net site and Elder Scrolls topics.
* FAQ    * Search
* Register    * Login
It is currently Fri May 17, 2024 2:20 am

Loading

All times are UTC

Post new topic Reply to topic  [ 25 posts ] 
Author Message
 Post subject: Scripting - Basics and Help
PostPosted: Sat Mar 13, 2010 12:18 pm 
Offline
Warder
Warder
User avatar

Joined: Sat Mar 29, 2008 3:04 pm
Posts: 564
ES Games: Arena, Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC
UESPoints: 0
It seems we have a fair few modders on here, but not all of them can script. If you have been wanting to write your own, but you're one of the people who are just overwhelmed by the complexity or you just haven't found a good guide to give you a head start, then you may find this thread helpful. Or if you've started scripting, but it just isn't working like it should and you need some help, feel free to ask here.

I shall begin by explaining the first few steps to writing your own script.
(Note: In each line, anything that is written behind a ; will be ignored by the game, it is just a note by the author, to help himself think, or in this case to explain to others. You may find it useful when writing yourself.)

Each script needs a beginning and an end. It should look like this:
Code:
begin my_first_script ; my_first_script being the unique name of your new script
end

This script will of course do nothing at all. In between those two lines though you add the rest of the script, for which you mostly use so called "if statements". A pretty common variable is OnActivate: 0 means not activated, and 1 means activated. Just like you close your script with an "end", each if statement must be closed with and "endif"
Here a simple example which will make the item you attach it to cast a spell on you when activated:
Code:
begin my_first_script

If ( OnActivate == 1) ; as explained above, this checks if the item is activated or not, and if it is it will continue to execute the following line
Cast,  "fireball", Player ; telling it to cast a fireball spell at you
Endif ; closing the if statement

end

Fancy, isn't it? ;) That will have to do for now, more is to follow soon. Feel free to ask any questions you may have or add your own tips and comments.

_________________
Nord wisdom:
You don't know a woman until you've had a strong drink and a fist fight with her.


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Sat Mar 13, 2010 1:13 pm 
Offline
Warder
Warder
User avatar

Joined: Thu Nov 13, 2008 5:33 pm
Posts: 417
Location: Good ol' blighty
ES Games: Oblivion, morrowind
Platform: PC
UESPoints: 0
Okay a little question to get it going, is it a similar procedure with all scripting (i.e. oblivion) or does it change?
Im a bit of a beginner even when comes to modding to be honest, but im starting to pick up the basics :wink:

_________________
The Friend Of The Night of The Brotherhood
"I didnt just fill a crate full of C4 and blow it up when my whole team was in there, you and your crazy accusations..."
Self proclaimed king of earl grey.


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Sat Mar 13, 2010 2:28 pm 
Offline
Journeyman
Journeyman
User avatar

Joined: Tue Nov 25, 2008 4:52 pm
Posts: 278
Location: El Paso
ES Games: Arena, Daggerfall, Morrowind GOTY, Oblivion GOTY, Skyrim, TES Construction Set
Platform: PC, Xbox, Xbox 360
Status: Living Life in Sun City..... I hate the Sun...
UESPoints: 0
Thanks Caz. Modding isnt as hard as it seemed when it first began. The only things I havent figured out so far, to my knowledge, are Journal entries and scripting.

_________________
"You there! Peasant!"
"Yes milord?"
"Destroy the Enemy Fortress!"
"...Okay :( "


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Sat Mar 13, 2010 4:08 pm 
Offline
Grand Master
Grand Master
User avatar

Joined: Mon Mar 08, 2010 3:19 pm
Posts: 1603
Location: Helsinki, Finland
ES Games: Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC desktop
Status: Concerning games, restarting my engine
UESPoints: 0
Thanks for your new thread. I'm sure it'll help many.

I know I haven't done any of my homework = manuals or anything, but I take the boldness to ask, is this done with The Elder Scrolls Construction Set? Or is it done with any text editor, and saved in some special file type?

Looking forward to participate in this great game. :D

_________________
Life is a comedy to those who think, a tragedy to those who feel. - Jean Racine


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Sat Mar 13, 2010 6:28 pm 
Offline
Journeyman
Journeyman
User avatar

Joined: Tue Nov 25, 2008 4:52 pm
Posts: 278
Location: El Paso
ES Games: Arena, Daggerfall, Morrowind GOTY, Oblivion GOTY, Skyrim, TES Construction Set
Platform: PC, Xbox, Xbox 360
Status: Living Life in Sun City..... I hate the Sun...
UESPoints: 0
@Andere, as far as I know its only in the script editor in the construction kit.

@anyone, Idk if this is done through script or if I am missing something. I need Helseth's death to trigger 2 things: a spawning of an NPC in the throne room, and a jorunal entry

the entry is noted as "TR_Helseth_Dead" at Index 20
If someone could post the script I need to trigger that Journal entry I would really appreciate it.

And the spawning... I have no idea how to do that, but I know thats through scripting. If someone could post the formula for that, it would be awesome.

_________________
"You there! Peasant!"
"Yes milord?"
"Destroy the Enemy Fortress!"
"...Okay :( "


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Sat Mar 13, 2010 6:57 pm 
Offline
Warder
Warder
User avatar

Joined: Sat Mar 29, 2008 3:04 pm
Posts: 564
ES Games: Arena, Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC
UESPoints: 0
@Hunter22: It's different, I've only tried scripting in Oblivion once and I had to use the CS wiki to help. The basic idea is the same though, if you understand one you should be able to understand the other :)

@Andere: You write the scripts in the CS itself and attach them to whatever you want. When I'm writing longer ones though I compose them in a normal editor and copy it over, I just find it easier to work with if it's going to take some time.
I have given your script some more thought, I think it should be possible with OnActivate and GetSecondsPassed. I am not yet entirely sure what it would look like though.

@Imperfect: This is not tested, but try something like this:
Code:
begin death_script

if (OnDeath == 1)
Journal, "TR_Helseth_Dead", 20
PlaceItemCell, ObjectID, CellID, X, Y, Z, ZRot ; here you'll need to add the NPC ID, the cell ID and the coordinates yourself
endif

end

_________________
Nord wisdom:
You don't know a woman until you've had a strong drink and a fist fight with her.


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Sat Mar 13, 2010 8:42 pm 
Offline
Journeyman
Journeyman
User avatar

Joined: Tue Nov 25, 2008 4:52 pm
Posts: 278
Location: El Paso
ES Games: Arena, Daggerfall, Morrowind GOTY, Oblivion GOTY, Skyrim, TES Construction Set
Platform: PC, Xbox, Xbox 360
Status: Living Life in Sun City..... I hate the Sun...
UESPoints: 0
Thanks Caz, I will test that next time I am in the CS.

_________________
"You there! Peasant!"
"Yes milord?"
"Destroy the Enemy Fortress!"
"...Okay :( "


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Sat Mar 13, 2010 9:46 pm 
Offline
Journeyman
Journeyman
User avatar

Joined: Tue Nov 25, 2008 4:52 pm
Posts: 278
Location: El Paso
ES Games: Arena, Daggerfall, Morrowind GOTY, Oblivion GOTY, Skyrim, TES Construction Set
Platform: PC, Xbox, Xbox 360
Status: Living Life in Sun City..... I hate the Sun...
UESPoints: 0
Alright Caz, got another one for you.

I need 3 characters: Sotha_sil_living1, vivec_god2, and almalexia_battle2 to disappear whenever I leave the Heart chamber, and I need them to never come back.

Any ideas?

_________________
"You there! Peasant!"
"Yes milord?"
"Destroy the Enemy Fortress!"
"...Okay :( "


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Sun Mar 14, 2010 3:07 pm 
Offline
Warder
Warder
User avatar

Joined: Sat Mar 29, 2008 3:04 pm
Posts: 564
ES Games: Arena, Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC
UESPoints: 0
Attach a script to something - the door, perhaps? - using the command "disable". You may want to use several if statements at once to make sure it happens at the right time (not before the death).
Do not attach it to the characters themselves, apparently that causes crashes. Have a go at writing it yourself ;)

_________________
Nord wisdom:
You don't know a woman until you've had a strong drink and a fist fight with her.


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Sun Mar 14, 2010 3:33 pm 
Offline
Grand Master
Grand Master
User avatar

Joined: Mon Mar 08, 2010 3:19 pm
Posts: 1603
Location: Helsinki, Finland
ES Games: Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC desktop
Status: Concerning games, restarting my engine
UESPoints: 0
Thanks Caz and Imperfect.

I downloaded some tutorials, and plan to start with "something" once I get my fingers off the game itself. I took part in a mod project for the game Freelancer, and it simply killed my playing - it went to "all work, no fun", and I'm not going to let that happen again.

Came to think, it would be wise to install a modding version of the game, in another partition? I have Windows XP Professional SP3, all updates, in partition C; then I have two other partitions, K and L. If I install MW in either K or L, will it have any consequences for the mod ( I hopefully manage to make :D )?

And, should I install everything up to Bloodmoon, plus MCP? Plus perhaps... what? In order to try to secure the compatibility, from the very start?

Please understand me, I suffer from the occupational disease of photographers, pedantry. Every dot and reflection has to be where I want them to be.

Finally, is the program Morrowind Script Editor v. 1.2 useable and reliable? I haven't tried it, no - no, but my earlier experiences with modding have shown, what you write is what you get, but various tools that make it all easier, aren't necessarily that reliable.

A lot of text once again, but I trust it will have an outcome. :roll: Like a Finnish proverb says,

It's good to live in Hope, said the tapeworm.

Thanks again m8s.

_________________
Life is a comedy to those who think, a tragedy to those who feel. - Jean Racine


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Sun Mar 14, 2010 8:08 pm 
Offline
Journeyman
Journeyman
User avatar

Joined: Tue Nov 25, 2008 4:52 pm
Posts: 278
Location: El Paso
ES Games: Arena, Daggerfall, Morrowind GOTY, Oblivion GOTY, Skyrim, TES Construction Set
Platform: PC, Xbox, Xbox 360
Status: Living Life in Sun City..... I hate the Sun...
UESPoints: 0
Alright. I know what you mean Andere, thats what this mod is turning into. I am working out a few small kinks. All thats left to do is fix Barenziah, who seems to not realize when her son is dead, and set those guys to disappear when I need them too.

_________________
"You there! Peasant!"
"Yes milord?"
"Destroy the Enemy Fortress!"
"...Okay :( "


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Wed Mar 17, 2010 4:34 am 
Offline
Journeyman
Journeyman
User avatar

Joined: Tue Nov 25, 2008 4:52 pm
Posts: 278
Location: El Paso
ES Games: Arena, Daggerfall, Morrowind GOTY, Oblivion GOTY, Skyrim, TES Construction Set
Platform: PC, Xbox, Xbox 360
Status: Living Life in Sun City..... I hate the Sun...
UESPoints: 0
Caz wrote:

@Imperfect: This is not tested, but try something like this:
Code:
begin death_script

if (OnDeath == 1)
Journal, "TR_Helseth_Dead", 20
PlaceItemCell, ObjectID, CellID, X, Y, Z, ZRot ; here you'll need to add the NPC ID, the cell ID and the coordinates yourself
endif

end


I forgot to mention, that script worked perfectly, but I cant figure out the scripting for the door. Once I do that, I will upload the mod for everyone.

_________________
"You there! Peasant!"
"Yes milord?"
"Destroy the Enemy Fortress!"
"...Okay :( "


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Wed Mar 17, 2010 1:21 pm 
Offline
Warder
Warder
User avatar

Joined: Sat Mar 29, 2008 3:04 pm
Posts: 564
ES Games: Arena, Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC
UESPoints: 0
Perhaps I should explain for everyone how we use multiple if statements at once. Basically, if two things are to be checked at the same time, you insert one inside the other, like so:
Code:
if (something)
if (something)
command
endif
endif


So your script, Imperfect, might look something like this:
Code:
begin door_script

if ( OnActivate == 1) ; when the door is opened
if ( GetJournalIndex, C3_DestroyDagoth >= 20 ) ; if you have a certain journal entry for this quest, here meaning after dagoth ur is killed
Sotha_sil_living1 -> disable
vivec_god2 -> disable
almalexia_battle2 -> disable ; all characters should disappear
endif
endif

end
Probably needs some tweaking... may need to add a GetDisabled line too.

And short note for everyone: you may know this already, but I'll put it down here for the record. When using if statements, you can use the following:
== : equal to
!= : not equal to
< : less than
> : greater than
<= : less than or equal to
>= : greater than or equal to

_________________
Nord wisdom:
You don't know a woman until you've had a strong drink and a fist fight with her.


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Wed Mar 17, 2010 3:15 pm 
Offline
Journeyman
Journeyman
User avatar

Joined: Tue Nov 25, 2008 4:52 pm
Posts: 278
Location: El Paso
ES Games: Arena, Daggerfall, Morrowind GOTY, Oblivion GOTY, Skyrim, TES Construction Set
Platform: PC, Xbox, Xbox 360
Status: Living Life in Sun City..... I hate the Sun...
UESPoints: 0
I will use that. Coding for this is different than stuff I am used to, like html

I preffer the virtual part of the construction set, that I can see what I am doing. :P

_________________
"You there! Peasant!"
"Yes milord?"
"Destroy the Enemy Fortress!"
"...Okay :( "


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Fri Mar 26, 2010 1:21 pm 
Offline
Warder
Warder
User avatar

Joined: Sat Mar 29, 2008 3:04 pm
Posts: 564
ES Games: Arena, Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC
UESPoints: 0
@Imperfect: how is that mod of yours going? Did the script work?
The virtual part is nicer to work with, but once you get the hang of scripting you can have much more fun in the game :D That's why I'm teaching myself.

@Andere: I think I finally got the hang of the timer scripts. Attach this to any doors you want to have close automatically:
Code:
begin automatic_door

short Open
float TimePassed ;this is declaring local variables, to be explained later


If ( Menumode == 1)
   return
endif

set TimePassed to ( TimePassed + GetSecondsPassed ) ;setting the timer

if ( OnActivate == 1 ) ;if activated
   if ( Open == 0 ) ;if it's not open already
      Activate ;open door
      set Open to 1 ;tells script that door is open
      set TimePassed to 0 ;reset timer to 0
   endif
endif

if ( Open == 1) ;the timer will only count if the door is open
   if ( TimePassed > 5 ) ;counts to 5 secs, change to whatever time you need
      activate ;close door again
      set Open to 0 ;tells script that door is closed, timer will not count
   endif
endif

end
Let me know if there is something you don't understand or if it doesn't work properly. I tested it though and it should be ok.

_________________
Nord wisdom:
You don't know a woman until you've had a strong drink and a fist fight with her.


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Thu Apr 01, 2010 12:01 pm 
Offline
Grand Master
Grand Master
User avatar

Joined: Mon Mar 08, 2010 3:19 pm
Posts: 1603
Location: Helsinki, Finland
ES Games: Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC desktop
Status: Concerning games, restarting my engine
UESPoints: 0
Hi Caz.

Thanks for your reminder PM, it got me working. :D

I tested the script, and it seems to work just fine. I'm a bit confused about two things, quite general by nature.

I have this tutorial Morrowind Scripting for Dummies. In their first example of writing a script, they create a Riddle Chest.

When I follow their instructions, everything goes well until the saving part. They don't mention saving an .esp file, but that's the only way I get the doors to function - if I don't save an .esp, and activate it in the game's Data Files, nothing happens, and the following time I open TES CS, there's no sign of the script - it has completely vanished.

Am I doing something wrong while saving?

They also ask to rename the object. My object is in_r_s_door_01, at Maar Gan Outpost. I renamed it to in_r_s_door_01b, but loading a game I got a warning, something like "can not find object in_r_s_door_01b". Of course, I know nothing about the principles of renaming... :?

But like I said, with an .esp it works.

Thanks and cheers.

_________________
Life is a comedy to those who think, a tragedy to those who feel. - Jean Racine


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Thu Apr 01, 2010 1:46 pm 
Offline
Warder
Warder
User avatar

Joined: Sat Mar 29, 2008 3:04 pm
Posts: 564
ES Games: Arena, Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC
UESPoints: 0
When modding you cannot modify the game directly, only create your own mod files, and they must be activated before starting the game. This is actually useful because take for example my case, when making a mod I somehow managed to shift a large part of the countryside without noticing. Sure, I had to delete my mod, but better that than reinstalling the whole game because you messed it up, aye? And this other time suddenly all the houses in Pelagiad disappeared (leaving only the doors), although my mod had nothing to do with that area... strange things have happened :P
So, a new .esp file for each mod. If you're making huge mods, it might be better to make several esps for it in case something goes seriously wrong (like mentioned above) and you won't need to start over.

Renaming objects. Well this is only for when you are creating new objects: entering a new one will make a new one, while leaving it unedited will write over the old one. In the case of your doors, you'd want to just add the script to as many doors in game as possible, without creating new ones, because in the visual part of the CS you can see that it would still be the original doors without scripts. You could always replace them all with your own doors, but thats just a load of unnecessary work.

Also, I wouldn't try adding the script to doors that take you to a different cell (into a building, for example). They are always "closed", so I don't know what would happen if you added that script to it. I can only think of one way to tell these kinds of doors apart: in the visual part of the CS, the normal doors look like doors from both sides, whereas the "teleporting" ones look like a door on one side, but on the other side it's practically invisible, as no texture has been added to the other side. Perhaps there's a different way to tell them apart without having to drag them all over and looking at them, but I can't think of one right now.

_________________
Nord wisdom:
You don't know a woman until you've had a strong drink and a fist fight with her.


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Thu Apr 01, 2010 2:31 pm 
Offline
Grand Master
Grand Master
User avatar

Joined: Mon Mar 08, 2010 3:19 pm
Posts: 1603
Location: Helsinki, Finland
ES Games: Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC desktop
Status: Concerning games, restarting my engine
UESPoints: 0
Very informative, Caz, thank you. :D

As far as I really understood it correctly, it seems like a pretty wise move to have to make a new .esp every time.

Another game I modded had the "Pelagiad syndrome": it was a space game with solar systems, planets and stuff, and when you did something... without success... the whole blasted system disappeared. :cry: In Morrowind, and my case right now, it would mean Maar Gan would disappear... what a fancy thought, though not desirable.. :shock:

Caz wrote:
Renaming objects. Well this is only for when you are creating new objects: entering a new one will make a new one, while leaving it unedited will write over the old one.

This is certainly a stupid question but: What would be a typical case of making a new object?

Caz wrote:
Also, I wouldn't try adding the script to doors that take you to a different cell (into a building, for example). They are always "closed", so I don't know what would happen if you added that script to it.

Well, in my case that's not even needed. Those doors are already automatic i.e., you actually just slip through them.

Thanks pal, Your advices are highly appreciated.

_________________
Life is a comedy to those who think, a tragedy to those who feel. - Jean Racine


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Thu Apr 01, 2010 3:24 pm 
Offline
Warder
Warder
User avatar

Joined: Sat Mar 29, 2008 3:04 pm
Posts: 564
ES Games: Arena, Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC
UESPoints: 0
Andere wrote:
Caz wrote:
Renaming objects. Well this is only for when you are creating new objects: entering a new one will make a new one, while leaving it unedited will write over the old one.

This is certainly a stupid question but: What would be a typical case of making a new object?

Hmm... for example, I want to make a ring with a certain spell on it. I could right click and press "new", then find the textures etc by myself. Or, the way I prefer doing it: I take one that already exists, make the changes and save as a new object, leaving all already existing objects with the old ID untouched, and my now magic ring a new, separate item.

Caz wrote:
Also, I wouldn't try adding the script to doors that take you to a different cell (into a building, for example). They are always "closed", so I don't know what would happen if you added that script to it.

Well, in my case that's not even needed. Those doors are already automatic i.e., you actually just slip through them.[/quote]
Precisely. But I do wonder what would happen if the script is attached to one of those... maybe you'd get taken back to where you were before? :lol: Or maybe nothing at all. I may try that out some time...

_________________
Nord wisdom:
You don't know a woman until you've had a strong drink and a fist fight with her.


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Thu Apr 01, 2010 4:27 pm 
Offline
Grand Master
Grand Master
User avatar

Joined: Mon Mar 08, 2010 3:19 pm
Posts: 1603
Location: Helsinki, Finland
ES Games: Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC desktop
Status: Concerning games, restarting my engine
UESPoints: 0
Alright... trying to get somewhat deeper into the world of scripts, are those empty spaces essential?

Like when you write

If ( Menumode == 1)
return
endif

you have three empty spaces in front of "return".

They won't show in this message, but they show in a text editor, and the Script Edit of TES CS. There are three blanks in front of "r" of return.

Are they essential? If they are, I guess it's a matter of experience to get them right? "What a beautiful world", eh?
??? I mean, usually (?) empty spaces don't mean anything, and if you want to excerpt something it's by a ;.

I'm really getting interested in this. How I'm going to make my "Caldera Ebony Mine War", I don't know, but my toes get warm...

Cheers,

Andere

_________________
Life is a comedy to those who think, a tragedy to those who feel. - Jean Racine


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Thu Apr 01, 2010 6:14 pm 
Offline
Grand Master
Grand Master
User avatar

Joined: Sun Aug 06, 2006 12:24 am
Posts: 2994
ES Games: Oblivion, Morrowind
Platform: PC
Status: Retired
UESPoints: 0
The three spaces is actually one hit on the tab key :wink: It's only purpose is to make the script easier to read; to see which "endif" belongs to which "if".

_________________
I used to play Oblivion, then I took an arrow in the knee.

A viking is just a horny pirate.


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Thu Apr 01, 2010 6:28 pm 
Offline
Grand Master
Grand Master
User avatar

Joined: Fri Mar 21, 2008 6:19 pm
Posts: 1518
Location: With Uncle Crassius and the Companion Cube
ES Games: Yes
Platform: 9¾ leaving in 5 minutes.
Status: Listening to They Might Be Giants
UESPoints: 0
Just a note from a bit of an amateur scripter (did a bit of Flash programming):
DEFINITELY USE WHITE SPACE
If you come back to a script after a while, it can be really confusing to work out which stuff is triggered when and when whatever ends and oh my this "for" command actually ends here and not here and frig that changes everything.

_________________
BANG → !


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Thu Apr 01, 2010 6:40 pm 
Offline
Warder
Warder
User avatar

Joined: Sat Mar 29, 2008 3:04 pm
Posts: 564
ES Games: Arena, Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC
UESPoints: 0
Correct, as they said it's just easier to read if you use tabs. :)

_________________
Nord wisdom:
You don't know a woman until you've had a strong drink and a fist fight with her.


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Thu Apr 01, 2010 7:45 pm 
Offline
Grand Master
Grand Master
User avatar

Joined: Mon Mar 08, 2010 3:19 pm
Posts: 1603
Location: Helsinki, Finland
ES Games: Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC desktop
Status: Concerning games, restarting my engine
UESPoints: 0
Ok, thanks friends.

I'll try to figure it out - without blowing the whole game up!

Ho-Ho, said Sancta Clause!

_________________
Life is a comedy to those who think, a tragedy to those who feel. - Jean Racine


Top
 Profile  
 
 Post subject: Re: Scripting - Basics and Help
PostPosted: Tue Apr 06, 2010 2:30 pm 
Offline
Warder
Warder
User avatar

Joined: Sat Mar 29, 2008 3:04 pm
Posts: 564
ES Games: Arena, Morrowind GOTY, Oblivion GOTY, Skyrim
Platform: PC
UESPoints: 0
Ok as promised, an explanation about variables.

There are two different types of variables, local and global ones. Here I shall explain local ones, the different types and how to define and set them.

Local variables belong only to whatever the script is attached to (global variables work on every script and can be set in the CS menu). You can name them whatever you want, provided it begins with a letter (you should also avoid using most characters too, as it can cause problems). All local variables must be declared (preferably) at the beginning of the script, like this:
Code:
short Open
float TimePassed

By default they are 0 until set to something else, using the "set" command, as such:
Code:
set Open to 1
set TimePassed to ( TimePassed + GetSecondsPassed )


There are three different kinds, depending on the numbers that it can take on: short, long and float.
  • Short variables are values from -32768 to 32767
  • Long variables are values from -2,147,483,648 to 2,147,483,647
  • Float variables are 3.4e +/- 38 (7 digits)

Examples:
  • Short: in the door script (see above) the variable for the door being open would only take on two numbers, 0 or 1 (closed and open), therefore I only need a short variable.
  • Long: similar to short, I believe, but can take on higher values
  • Float: also in the door script, the time can take on decimal numbers, so it is a float variable

Questions? :D

_________________
Nord wisdom:
You don't know a woman until you've had a strong drink and a fist fight with her.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 25 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Sponsored Links

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group