Aller au contenu

Photo

SOLVED: Script Help - How to call a script from within a script


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

#1
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
I have a utility script to restart ambient behaviours following certain events - most often I am calling this at the end of dialogue, but in a couple of cases, I need to call another script first at the end of the dialoue.  Now instead of duplicating my ambient restart script in other scripts, I woud like to just call the one that is already setup (for obvious reasons).

What's the code to do this?

Modifié par RecklezzRogue, 22 juin 2010 - 03:07 .


#2
Phaenan

Phaenan
  • Members
  • 315 messages
Probably not that clean, but I usually use HandleEvent() for that purpose since the second param' allows to precise which script will handle the event. (it's possible to use a "false" event if need be)

#3
TimelordDC

TimelordDC
  • Members
  • 923 messages
Or put the code to restart the ambient behaviour as a function in an include script and call the functions in the scripts you want.

#4
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
ok - thanks - I thought about using handleevent - it should work for the purpose I have (which is very limited in scope).



Now - setting up a function, i've not yet learned how to do that, but I can see how that would be really scalable...for other non-area specific things...I'll read up on that.



so there's no "RunScript" type command....that explains why I couldn't find one ;-)


#5
CID-78

CID-78
  • Members
  • 1 124 messages
there is executeScript() still around, it's noted as obsolete however. I think it's because they want people to use Handleevent. But i think it still works.

#6
FergusM

FergusM
  • Members
  • 460 messages
DelayEvent() can also be used if you find that the scripts need to be run one after the other. Sometimes if you run things simultaneously they won't work.

#7
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
I'll check those out tonight - for now I am using handleevent with the resource explicitly named and that does work, but it feels like cheating ;-)


#8
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
I am settling on HandleEvent --- I can't as yet see any reason this won't work, and I was able to integrate it into my scripts quite easily.



Note - I am inspired to learn how to set up functions now, as I can see there is real value relative to scalability...but this post is solved ;-)


#9
indio

indio
  • Members
  • 204 messages
if(!nEventHandled)
    {
        HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
        resource rScriptName = R"scriptname.ncs";
        HandleEvent(ev, rScriptName);

    }

Phaenan helped me out a few days ago with just the solution you're after. Works great.

#10
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages
Yep indio - I took a shortcut as follows:



HandleEvent (ev, R"dmo001_dafl001d_res_ambient.ncs");

#11
indio

indio
  • Members
  • 204 messages
Ooh. Nice.

#12
RecklezzRogue

RecklezzRogue
  • Members
  • 193 messages

RecklezzRogue wrote...

Yep indio - I took a shortcut as follows:

HandleEvent (ev, R"dmo001_dafl001d_res_ambient.ncs");


I take that back...lol...using indio's approach.