Hey im having a little trouble wrapping my head around running scripts based on a specific event.
Say for example, i want to run a script any time someone equips a piece of gear. i want this script to run any time someone equips gear, no matter what gear is equipped.
what would be the simplest way to do that?
Simple event scripting
Débuté par
Nasai1
, févr. 13 2011 08:04
#1
Posté 13 février 2011 - 08:04
#2
Posté 13 février 2011 - 08:12
#3
Posté 13 février 2011 - 09:03
To affect equipping for individual items tag-based scripting is the best approach; to affect equipping of everything you can create your own On Player Equip script to behave as you wish.
Regards
Regards
#4
Posté 14 février 2011 - 01:50
Kaldor Silverwand wrote...
To affect equipping for individual items tag-based scripting is the best approach; to affect equipping of everything you can create your own On Player Equip script to behave as you wish.
Regards
i'd really like to use the second option. Im just wondering how i can set it up so that it actually triggers any time an item is equipped. I have an intermediate level of programming experience, and even after reading that guide, i am still a little unsure as to what triggers the script in the first place.
My best guess is that the naming convention of the script file itself has something to do with it. does the game just run every script file with the appropriate prefixes and extensions? like if a player equips an item, are all scripts that start with i_ and end with _eq executed, and then the scripts are expected to check conditionals theirselves?
if this is the case, then i guess all i have to do is make a script file with that convention and then go from there, and i shouldn't need any more help.
if that's not the case, then could someone explain to me exactly how the scripts are triggered? keep in mind i want the script to run anytime any item is equipped, and i really dont want to have to modify the tags of all items in game.
#5
Posté 14 février 2011 - 02:00
How it works is the module has a on used event. The "second" method, is a script you code yourself, but most of them also support tag based scripts. This allows you to do multiple things without causing many issues for yourself, and makes it work with the OC and community modules. This event fires ANY time ANY ITEM is used.
Once that is set up you just have to name it correctly for each individual script, which is good since you can integrate with the OC or the like without having to use the toolset on the module.( ie i_tagname_2lettercode - look at the link i posted which explains this.)
Once that is set up you just have to name it correctly for each individual script, which is good since you can integrate with the OC or the like without having to use the toolset on the module.( ie i_tagname_2lettercode - look at the link i posted which explains this.)
#6
Posté 14 février 2011 - 02:04
Nasai1,
You are confusing tag-based scripting with event scripts. They really aren't the same.
Tag-based scripts are item specific based on the tag of the item. They are initiated based on their name. So you can use a script named i_mytag_eq to execute every time an item with tag "mytag" is equipped.
Event scripts are scripts that are set in the properties of an object so that when certain events happens to that object the script is executed. So a player on equip script, which is a property of the module, can be used anytime a player equips any item. These scripts are generally assigned to a module. Look at the module properties and you will see that there are properties for several events like on death, on activate, on equip, and on unequip. The event scripts can be named anything you want, but normally they are named k_mod_action, like k_mod_equip for an equip script or k_mod_unequip for an unequip script. But the naming is only convention and makes no real difference.
Regards
You are confusing tag-based scripting with event scripts. They really aren't the same.
Tag-based scripts are item specific based on the tag of the item. They are initiated based on their name. So you can use a script named i_mytag_eq to execute every time an item with tag "mytag" is equipped.
Event scripts are scripts that are set in the properties of an object so that when certain events happens to that object the script is executed. So a player on equip script, which is a property of the module, can be used anytime a player equips any item. These scripts are generally assigned to a module. Look at the module properties and you will see that there are properties for several events like on death, on activate, on equip, and on unequip. The event scripts can be named anything you want, but normally they are named k_mod_action, like k_mod_equip for an equip script or k_mod_unequip for an unequip script. But the naming is only convention and makes no real difference.
Regards
Modifié par Kaldor Silverwand, 14 février 2011 - 02:06 .
#7
Posté 14 février 2011 - 03:35
oh okay i understand now. last question:
is it possible to use a module for this script and then apply that module to an OC game save already in progress?
is it possible to use a module for this script and then apply that module to an OC game save already in progress?
#8
Posté 14 février 2011 - 04:38
Yes. If you want to override the standard module on equip script used by the OC then just name your script k_mod_player_equip. compile it with the toolset and put the compiled version (k_mod_player_equip.ncs) in your override folder.
Regards
Regards





Retour en haut






