Harushimo Posted December 5, 2009 Share Posted December 5, 2009 Already tried posting this once, so let's hope it works the second time.Here's the Deal. I need to know if there's a command or function in scripting that will allow me to have one script change a value in another script. For example, can I make ScriptA with it's Short Bodycount variable be changed by a script running on Goblin01 that checks to see when it's been killed? I realize I could make one script that checks if Goblin01 is dead, and if so, adds one to the Bodycount Variable (Though using set Bodycount to bodycount +1 seems to be screwing up majorly), but when I've got 8 goblins, and 5 other sets of 8 creatures, totalling 48 creatures, the IF getisdead Blocks start to add up. Then throw in that I made a reward script that gives you better stuff depending on what the Bodycount is, putting it all in one script becomes huge and it seems that only so many IF statements will work in one. So, to sum it up, is there a way to make Script A change a value in Script B, and then have Script C check that value and act accordingly? Link to comment Share on other sites More sharing options...
Vagrant0 Posted December 5, 2009 Share Posted December 5, 2009 Yes, by attaching script A to a quest or other persistent object. The syntax would be something likebegin ondeath set bodycount to <script A ref>.bodycount set <script A ref>.bodycount to bodycount + 1 endon the goblin, andif <script A ref>.bodycount >= <value> && <script A ref>.bodycount2 >= <value> ;;; do stuff;;; The main thing to remember is that to detect a non-local variable (variable in another script) in a script, you need that variable to be present on a persistent, known object. In order order to use that non-local variable as an output for a function, you often need to duplicate the value to a local script (variable in the same script) first, and need to perform everything you want to do before changing the non-local variable to match the local one. It's a bit confusing at first, so if you're having trouble you might want to try doing it on a small scale before applying it to a grand project. Something simple like a button script which increases a variable in a quest script paired with a chest that unlocks after that variable has been reached should illustrate the concept. Link to comment Share on other sites More sharing options...
Harushimo Posted December 5, 2009 Author Share Posted December 5, 2009 :thanks: Awesome! Thank you VERY much. I'll definitely have to play with it and practice on smaller projects like you said, but once I get the hang of it I have a ton of things I want to try! ^_^ Once again, thanks. If you by chance know where you learned that, if it was in a tutorial or something, that would also be helpfull, but I think I'll be able to figure it out from that with enough trial and error. Not knowing how to do this was a huge hurdle in my way for the puzzles in the Dragon Paths. Link to comment Share on other sites More sharing options...
Recommended Posts