i'd like to run a script from a script if a plot flag has been set but i don't know what function to use.
running a script from another script
Débuté par
gordonbrown82
, juil. 25 2010 06:18
#1
Posté 25 juillet 2010 - 06:18
#2
Posté 25 juillet 2010 - 06:49
#3
Posté 25 juillet 2010 - 10:52
according to that i should use an event but i'm unsure how.
when a plot flag is set a certain code should be run, like below but with the code being in a reffered script instead of in the script below (that is from a trigger).
if(WR_GetPlotFlag(PLT_CAVE2_PLOTS, SEEN_FIRST_SCENE) == FALSE)
{
location lSpawn = GetLocation(GetObjectByTag("wp_cannonleft"));
CreateObject(32, R"scout_enemy_prelude4.utc", lSpawn);
BeginConversation(GetHero(), GetObjectByTag("scout_enemy_prelude4"));
}
when a plot flag is set a certain code should be run, like below but with the code being in a reffered script instead of in the script below (that is from a trigger).
if(WR_GetPlotFlag(PLT_CAVE2_PLOTS, SEEN_FIRST_SCENE) == FALSE)
{
location lSpawn = GetLocation(GetObjectByTag("wp_cannonleft"));
CreateObject(32, R"scout_enemy_prelude4.utc", lSpawn);
BeginConversation(GetHero(), GetObjectByTag("scout_enemy_prelude4"));
}
#4
Posté 26 juillet 2010 - 04:07
As shown in the other thread, if you use HandleEvent, passing the event you're already handling as the first parameter, it's simply a request to run a script. No need to create a new event.
Alternatively, you can use WR_SetPlotFlag with the last parameter set to TRUE to fire a plot script. That can be more elegant if the script you're trying to run is plot-related, because it keeps all the plot logic in one place.
Alternatively, you can use WR_SetPlotFlag with the last parameter set to TRUE to fire a plot script. That can be more elegant if the script you're trying to run is plot-related, because it keeps all the plot logic in one place.
#5
Posté 26 juillet 2010 - 07:58
what's a plot scrip?
#6
Posté 26 juillet 2010 - 08:06
and what do you mean by passing the event you're already handling as the first parameter?
#7
Posté 27 juillet 2010 - 12:09
"what's a plot scrip?"
When you have your plot open in the toolset, look down to the right-hand side where you can see the plot name, type of plot and the like, and you'll see that there is a script running there (plot_core or something similar.) That script handles events every time you trip a flag on this plot, so in there - well, in a custom copy that you create and run there - you can use those flag events to perform whatever you want to do.
When you have your plot open in the toolset, look down to the right-hand side where you can see the plot name, type of plot and the like, and you'll see that there is a script running there (plot_core or something similar.) That script handles events every time you trip a flag on this plot, so in there - well, in a custom copy that you create and run there - you can use those flag events to perform whatever you want to do.
#8
Posté 27 juillet 2010 - 04:45
Have a look at the script overview in the wiki, following the link to the discussion of events. The plot section is also useful.
A script is normally triggered by an event, i.e. when something pre-defined happens, such as module start, area load, player clicks on placeable or a plot flag is changed.
Most objects (module, areas, creatures etc) have an event script which is triggered by certain events. For example, MODULE_START will always fire the module script, USE will always fire the script of the placeable that's just been clicked.
Very often, the first line of a script discovers which event triggered it, for example
The HandleEvent function expects to be told "handle event x by running script y". If you just want it to run another script, you can pass the event that started your current script (just to satisfy the syntax).
In DAO, a plot is an object, just like a creature or a trigger. So, it has an event script in its properties, which fires when certain events occur - for example, when a plot flag is set or cleared.
The event and plot concepts are quite difficult to understand, but once you've grasped them, you'll have a very powerful insight into scripting.
A script is normally triggered by an event, i.e. when something pre-defined happens, such as module start, area load, player clicks on placeable or a plot flag is changed.
Most objects (module, areas, creatures etc) have an event script which is triggered by certain events. For example, MODULE_START will always fire the module script, USE will always fire the script of the placeable that's just been clicked.
Very often, the first line of a script discovers which event triggered it, for example
event ev = GetCurrentEvent();
The HandleEvent function expects to be told "handle event x by running script y". If you just want it to run another script, you can pass the event that started your current script (just to satisfy the syntax).
In DAO, a plot is an object, just like a creature or a trigger. So, it has an event script in its properties, which fires when certain events occur - for example, when a plot flag is set or cleared.
The event and plot concepts are quite difficult to understand, but once you've grasped them, you'll have a very powerful insight into scripting.





Retour en haut






