Phendrena Posted October 15, 2012 Hi, I would like to have the player walk over a linedef that triggers an ACS script (D-in-H format). The script will ideally lower a random platform, delay for about 20 seconds and then lower another random platform and so on until all eight platforms have been lowered. While I can do simple scripts, I can't work out how I would be able to do this? Would anyone be able to provide an example please. Thanks, Dave 0 Share this post Link to post
Gez Posted October 15, 2012 Something like this should work. script "Platform Sequence" () { int i; int platforms[8] == { 1, 2, 3, 4, 5, 6, 7, 8 }; for (i = 0; i < 8; ++i) { int j = random(i, 7); int platform = platforms[j]; platforms[j] = platforms[i]; Floor_LowerToLowest(platform, 32); // or Floor_LowerByValue or whatever delay(20*35); } }The platforms array (note the plural) contains the TIDs of the eight different platforms. In this example, they are 1 to 8, but they could be anything else. The script will loop eight times. Each time, it'll pick a random number between the iteration (so, 0 the first time, 1 the second, 2 the third, etc. until 7 on the eighth) and 7. The TID from the array at that index is chosen as being our random platform for this iteration. Then the value in the array is replaced by one that hasn't been used yet. (Though it might happen that it gets replaced by itself if the minimum was rolled. Not a problem.) The loop waits for twenty second. This way, we make sure that a same platform will not be randomly chosen twice. 0 Share this post Link to post
Phendrena Posted October 15, 2012 Cheers Gez, You really rather good at all this :) My ideas outweight my skills atm. I am learning and I'll get there eventually!! Dave 0 Share this post Link to post
Phendrena Posted October 15, 2012 Hi Gez, A couple of problems with the script... script "Platform Sequence" () DB2 gives an error regarding the script number or lack of, so adding one in,script 2 "Platform Sequence" () also errors with bad script declaration. If i change it to read,script 2 (void) does compile further but errors at this point;int platforms[8] == { 9, 10, 11, 12, 13, 14, 15, 16 }; gives the errors, 1 Only map variables can be arrays 2 Invalid identifier Any suggestions?? Cheers, Dave 0 Share this post Link to post
gggmork Posted October 15, 2012 I'm pretty sure arrays have to be global. So declare the array outside any script. Also I think just a simple mistake: = instead of == in that case (former is assignment operator, last means equals 0 Share this post Link to post
Phendrena Posted October 15, 2012 gggmork said:I'm pretty sure arrays have to be global. So declare the array outside any script. Also I think just a simple mistake: = instead of == in that case (former is assignment operator, last means equals Ok, So I would take the following; int platforms[8] = { 1, 2, 3, 4, 5, 6, 7, 8 };and stick it after the #include line. I'll give it a whirl in the morning as I'm off to bed now! Thanks for all the help and the patience, Dave 0 Share this post Link to post
Gez Posted October 15, 2012 Phendrena said:Hi Gez, A couple of problems with the script... script "Platform Sequence" () I gave you a named script for the example. If you haven't updated the ACC from the one that was provided with DB2, it's not going to work. Just replace the name with a number then. For the other two things, gggmork is correct. 0 Share this post Link to post
Phendrena Posted October 16, 2012 It is all working rather nicely now and will (hopefully) be quite a nasty surprise!! Thank you all for you help :) Dave 0 Share this post Link to post