Aller au contenu

Photo

running a script from another script


  • Veuillez vous connecter pour répondre
7 réponses à ce sujet

#1
gordonbrown82

gordonbrown82
  • Members
  • 544 messages
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.

#2
_L_o_B_o_

_L_o_B_o_
  • Members
  • 117 messages
 Hope it helps you...

http://social.biowar...1/index/2906004

#3
gordonbrown82

gordonbrown82
  • Members
  • 544 messages
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"));

}

#4
Proleric

Proleric
  • Members
  • 2 354 messages
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.

#5
gordonbrown82

gordonbrown82
  • Members
  • 544 messages
what's a plot scrip?

#6
gordonbrown82

gordonbrown82
  • Members
  • 544 messages
and what do you mean by passing the event you're already handling as the first parameter?




#7
BillHoyt

BillHoyt
  • Members
  • 109 messages
"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.

#8
Proleric

Proleric
  • Members
  • 2 354 messages
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

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.