Jump to content

Scripting


Korodic

Recommended Posts

For those confused about CK opening an external program when editing scripts:

There is no internal editor in CK.

 

I've setup notepad++ using this guide, and its pretty neat:

http://www.creationkit.com/Notepad%2B%2B_Setup

Actually, there is an internal editor. BUT that setup is better for serious scripts. Read up ^^ to see the internal editor. Personally, i think they only use the internal for quick edits and the external for the original writing.

Link to comment
Share on other sites

I am having the same problem. Any ideas on why?

 

Well ive just spent the last hour trying to get an npc to spawn when NPC No.1 dies.

Followed all the tutorials but everytime it says it has failed, if anyone can explain as the wiki just makes things far more confusing

 

I even tried copying the scripts they told you to try and I still get an error saying its wrong

 

one thing that has changed is that scripts now have a degree of scoping. Basically there are a lot of things that can't be directly accessed like in previous games.

 

I can't tell you exactly how to fix your problem but maybe I can show you what I've done to help you out. I was trying to add a perk using a quest but kept running into compiler errors eventually I figured out I needed to add properties to my script.

 

This is actually a script fragment in the quest editor but you can do the same thing by right clicking a script in the resource you added it and select Edit Properties

http://i.imgur.com/0vTubh.png

 

http://i.imgur.com/lsoRVh.png

 

A new dialogue should popup, you'll new to select the type and give it a name. I found when I gave it the same name as a resource that already exists it automatically found the item.

http://i.imgur.com/lAUcph.png

 

If it doesn't find it automatically you'll need to do it yourself

http://i.imgur.com/RFvxLh.png

http://i.imgur.com/faP1Kh.png

 

This should allow you to use the item in your script. Hope this helps.

Link to comment
Share on other sites

I really do like the new language despite the added complexity. Little things I've noted:

 

"Variables" are now local variables. "Properties" are the equivalent of global or public variables.

Yay loops!

Yay external editor support! I'm going to investigate the feasibility of writing a NetBeans or Eclipse environment for script devving.

Glad that they implemented some things to save time. For example, now they have both OnEquipped and OnObjectEquipped events, which is very handy if you don't want OnEquipped on an object (for instance, armors from the standard game).

Very happy that we now have real function support, extends, no more stupid GameMode timers, etc. Even little things like initializing a variable on declaration - you couldn't do that originally, which is so 1980s.

Yay for trig and radian/degrees! You might say WTF, but they are indispensable for anything that aims, flight mods, etc etc.

 

It'll take a few days to absorb everything. I'm going to make simple toy mods until I get more familiar, then start on my banking mod project.

Edited by jimhsu
Link to comment
Share on other sites

OMG, you can pass entire objects as properties? This will be fun...

 

int Property NumShots ;This is what's seen externally

int Function get()

return shotCount

endFunction

 

Function set(int value)

if (value > 50) ;value is too big, so clamp it at 50 and write a warning to debug

debug.trace ( "Tried to set NumShots to a number over 50. Clamping to 50" )

shotCount = 50

elseIf (value < 1) ;value can't be less than one or there would be nothing to shoot.

debug.trace ( "Can't set value to less than one. Not going to change the value." )

else ;everything's ok, just set value to the number of shots

shotCount = value

endIf

endFunction

endProperty

 

That's an object right there...

Link to comment
Share on other sites

I do appreciate the support it offers, but the properties are getting me crazy confused. They aren't exactly global variables, because global variables are global variables XD But I know enough to make things work.
Link to comment
Share on other sites

I do appreciate the support it offers, but the properties are getting me crazy confused. They aren't exactly global variables, because global variables are global variables XD But I know enough to make things work.

 

Think of them as public variables, not global variables (taking Java as an example). Public variables are associated with a script, but can be accessed externally (either directly, or via accessors [as my example shows]). Global variables on the other hand are part of the game itself and not associated with any script. There is a distinction, but whether or not it's important depends what you're doing. Properties (public variables) can share the same name across different scripts (i.e. DragonFireBreath), but globals can't.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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