HarryDudE Posted October 9, 2023 (edited) So I'm having some trouble making a script very similar to the switch sequence in Quake. So far I have a script where if I press Three switches it opens a door, Here's what it looks like: int totalswitches = 3; int switchcount; script 2 (void) { switchcount++; if (switchcount >= totalswitches) { Door_Open(25, 32, 0); } } But I'd want to make it when you each switch press a message pops up saying "Three more to go", "Two more to go", And so on After all Three switches are pressed I want it to finish off with a message saying "A door has opened..." Thanks! Edited October 9, 2023 by HarryDudE 0 Quote Share this post Link to post
Edward850 Posted October 9, 2023 (edited) This is a fizzbuzz problem with multiple solutions, but here's a couple of quick ones: int totalswitches = 3; int switchcount; str switchmessage[3] = { "Two more to go", "One more to go", "The door is now open" }; script 2 (void) { if (switchcount >= totalswitches) { // Avoid doing out of bounds read if too many switches placed. terminate; } print(s:strings[switchcount]); switchcount++; if (switchcount >= totalswitches) { Door_Open(25, 32, 0); } } int switchcount; script 2 (void) { switchcount++; switch(switchcount) { case 1: Print(s:"Two more to go"); break; case 2: Print(s:"One more to go"); break; case 3: Print(s:"The door is now open"); Door_Open(25, 32, 0); break; } } Edited October 9, 2023 by Edward850 0 Quote Share this post Link to post
HarryDudE Posted October 10, 2023 2 hours ago, Edward850 said: This is a fizzbuzz problem with multiple solutions, but here's a couple of quick ones: int totalswitches = 3; int switchcount; str switchmessage[3] = { "Two more to go", "One more to go", "The door is now open" }; script 2 (void) { if (switchcount >= totalswitches) { // Avoid doing out of bounds read if too many switches placed. terminate; } print(s:strings[switchcount]); switchcount++; if (switchcount >= totalswitches) { Door_Open(25, 32, 0); } } int switchcount; script 2 (void) { switchcount++; switch(switchcount) { case 1: Print(s:"Two more to go"); break; case 2: Print(s:"One more to go"); break; case 3: Print(s:"The door is now open"); Door_Open(25, 32, 0); break; } } Thank you very much! Got it to work 0 Quote Share this post Link to post
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.