Author Topic: Double script question  (Read 326 times)

Legacy_Agent81

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Double script question
« on: April 19, 2014, 03:41:38 am »


               

I'm just recently getting back into this game after about a 6 year hiatus. I still kinda sorta remember a great deal of basic scripting stuffs but I forgot a good majority of the other stuff. One in particular was how to have more than one script tied to a specific part of the item or module. For example, if I have two different scripts that both go in the "module heartbeat" but I have no idea how to get both of them to take effect. Is there any way to make this happen? Like a line of text used a separator or something? Any help would be greatly appreciated. 


 


-Agent



               
               

               
            

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
Double script question
« Reply #1 on: April 19, 2014, 03:49:22 am »


               Welcome back!  


One way would be to merge the two scripts into a single script that accomplished both tasks.


Or, you could make one of the scripts execute the other once it finishes.  Or, you could make one of the scripts a function and call it from within the first script.


Without knowing more, it's kind of hard to say what might be preferable, if any.  There are a few different approaches you could take,
               
               

               
            

Legacy_ruadhri10

  • Jr. Member
  • **
  • Posts: 52
  • Karma: +0/-0
Double script question
« Reply #2 on: April 19, 2014, 02:43:50 pm »


               

I hope I understand what you're asking.


My solution - create a new script file, and save it as "mod_hb_wrapper".


 


void main ()


{


    ExecuteScript("FIRSTSCRIPT",OBJECT_SELF);


    ExecuteScript("SECONDSCRIPT",OBJECT_SELF);


}


Then put mod_hb_wrapper in your Module Heartbeat event.


Is that what you meant?



               
               

               
            

Legacy_Agent81

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Double script question
« Reply #3 on: April 21, 2014, 09:29:05 pm »


               


I hope I understand what you're asking.


My solution - create a new script file, and save it as "mod_hb_wrapper".


 


void main ()


{


    ExecuteScript("FIRSTSCRIPT",OBJECT_SELF);


    ExecuteScript("SECONDSCRIPT",OBJECT_SELF);


}


Then put mod_hb_wrapper in your Module Heartbeat event.


Is that what you meant?




 


Maybe. I don't really have a great example of what I'm talking about so let me see if I can explain. lol


 


In the module heartbeat spot I'd have a script that pretty much watches the torch usage of a PC so that the torch will "burn out" after a set time of use and be destroyed. But at the same time I have a script that would also go in the module heartbeat that watches the day/night cycle and automatically turns on/off street lamps as the time cycles between night/day. Two different scripts that don't run off each other but both go into the same place of the module. 


 


Please note that these are just examples and I don't actually have the scripts or anything. Just wondering if there's a way to do it so two or more scripts would function separately but in the same spot. 


               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
Double script question
« Reply #4 on: April 21, 2014, 11:06:19 pm »


               ruadhri10's solution does exactly that, calling each script in turn. That way, you don't have to touch the scripts themselves.


Better still, edit the default Bioware script, to ensure you still have all that goodness. Before the final }, add the content of the two scripts, one after the other. By "content", I mean the lines following


void main{


excluding the final }. Or add ruadhri10's content - the end result is the same, I just find it easier to find stuff if it's all in one place. If your scripts are very long, you can code them as functions, once you feel confident about scripting.


By all means post your scripts here (preferably using the spoiler and code BBCodes) if that isn't clear.