cassiannn Posted September 29, 2017 Share Posted September 29, 2017 (edited) So I've been working on recreating Hopper31's Radio Reinforcements mod which you can see being used in some of Alchestbreach's videos. It's gone well so far, I just can't get the spawn menu to work. This is the full code: ScriptName RadioReinforcementsScript short bKeyPressed short iButton0 short iButton1 short iOtherMenu Begin GameMode if bKeyPressed != IsKeyPressed 48 ; B set bKeyPressed to IsKeyPressed 48 ; B if bKeyPressed ; Button Pressed ShowMessage RadioReinforcementsMenu endif endif End Begin GameMode set iButton0 to GetButtonPressed if iButton0 == -1 ; No button pressed yet Return elseif iOtherMenu == 0 ; First Menu if iButton0 == 0 ; Unit Selection ShowMessage RadioReinforcementsUnitMenu set iOtherMenu to 1 Return elseif iButton0 == 1 ; Close ; Close the menu endif elseif iOtherMenu == 1 ; Second Menu set iButton1 to GetButtonPressed if iButton == -1 Return elseif iButton1 == 0 ; 1 Unit player.PlaceAtMe RadioSpawnerAlly 1 set iOtherMenu to 0 elseif iButton1 == 1 ; 2 Units player.PlaceAtMe RadioSpawnerAlly 2 set iOtherMenu to 0 elseif iButton1 == 2 ; 3 Units player.PlaceAtMe RadioSpawnerAlly 3 set iOtherMenu to 0 elseif iButton1 == 3 ; 4 Units player.PlaceAtMe RadioSpawnerAlly 4 set iOtherMenu to 0 elseif iButton1 == 4 ; 5 Units player.PlaceAtMe RadioSpawnerAlly 5 set iOtherMenu to 0 elseif iButton1 == 5 ; 6 Units player.PlaceAtMe RadioSpawnerAlly 6 set iOtherMenu to 0 elseif iButton1 == 6 ; 7 Units player.PlaceAtMe RadioSpawnerAlly 7 set iOtherMenu to 0 elseif iButton1 == 7 ; 8 Units player.PlaceAtMe RadioSpawnerAlly 8 set iOtherMenu to 0 endif endif End This whole section works just fine: Begin GameMode if bKeyPressed != IsKeyPressed 48 ; B set bKeyPressed to IsKeyPressed 48 ; B if bKeyPressed ; Button Pressed ShowMessage RadioReinforcementsMenu endif endif End Begin GameMode set iButton0 to GetButtonPressed if iButton0 == -1 ; No button pressed yet Return elseif iOtherMenu == 0 ; First Menu if iButton0 == 0 ; Unit Selection ShowMessage RadioReinforcementsUnitMenu set iOtherMenu to 1 Return elseif iButton0 == 1 ; Close ; Close the menu endif and clicking 'Unit Selection' takes you to the second menu, but none of the buttons in the second menu actually do anything and upon opening the first menu a second time and clicking 'Unit Selection', nothing happens. Any help, or even some examples, would be greatly appreciated because I have no idea what's going wrong. Edited September 29, 2017 by Sabovich Link to comment Share on other sites More sharing options...
DoctaSax Posted September 30, 2017 Share Posted September 30, 2017 After pressing the button stored in iButton0 in iOtherMenu 0, you're taken to iOtherMenu1. The button you're pressing there, stored in Button1, isn't detected because the value in Button0 has been reset when you clicked that, blocking the rest of the script.There's no point in operating two vars to store the buttonpress in. You should also avoid having 2 of the same blocktypes in a single script, and probably work in some safety so that people pressing the key too long aren't persented with multiple versions of the same menu. Suggestion: int bKeyPressed int iButton int iGo int iOtherMenu Begin GameMode if bKeyPressed != IsKeyPressed 48 ; B set bKeyPressed to IsKeyPressed 48 ; B if bKeyPressed ; Button Pressed set iGo to 1 ShowMessage RadioReinforcementsMenu endif endif if iGo set bKeyPressed to 0 else return endif set iButton to GetButtonPressed if iButton == -1 ; No button pressed yet Return elseif iOtherMenu == 0 && iButton == 0; First Menu set iOtherMenu to 1 ShowMessage RadioReinforcementsUnitMenu return elseif iOtherMenu == 1 ; Second Menu set iOtherMenu to 0 if iButton == 0 ; 1 Unit player.PlaceAtMe RadioSpawnerAlly 1 elseif iButton == 1 ; 2 Units player.PlaceAtMe RadioSpawnerAlly 2 elseif iButton == 2 ; 3 Units player.PlaceAtMe RadioSpawnerAlly 3 elseif iButton == 3 ; 4 Units player.PlaceAtMe RadioSpawnerAlly 4 elseif iButton == 4 ; 5 Units player.PlaceAtMe RadioSpawnerAlly 5 elseif iButton == 5 ; 6 Units player.PlaceAtMe RadioSpawnerAlly 6 elseif iButton == 6 ; 7 Units player.PlaceAtMe RadioSpawnerAlly 7 elseif iButton == 7 ; 8 Units player.PlaceAtMe RadioSpawnerAlly 8 endif endif set iGo to 0 End Link to comment Share on other sites More sharing options...
cassiannn Posted October 1, 2017 Author Share Posted October 1, 2017 After pressing the button stored in iButton0 in iOtherMenu 0, you're taken to iOtherMenu1. The button you're pressing there, stored in Button1, isn't detected because the value in Button0 has been reset when you clicked that, blocking the rest of the script.There's no point in operating two vars to store the buttonpress in. You should also avoid having 2 of the same blocktypes in a single script, and probably work in some safety so that people pressing the key too long aren't persented with multiple versions of the same menu. Suggestion: int bKeyPressed int iButton int iGo int iOtherMenu Begin GameMode if bKeyPressed != IsKeyPressed 48 ; B set bKeyPressed to IsKeyPressed 48 ; B if bKeyPressed ; Button Pressed set iGo to 1 ShowMessage RadioReinforcementsMenu endif endif if iGo set bKeyPressed to 0 else return endif set iButton to GetButtonPressed if iButton == -1 ; No button pressed yet Return elseif iOtherMenu == 0 && iButton == 0; First Menu set iOtherMenu to 1 ShowMessage RadioReinforcementsUnitMenu return elseif iOtherMenu == 1 ; Second Menu set iOtherMenu to 0 if iButton == 0 ; 1 Unit player.PlaceAtMe RadioSpawnerAlly 1 elseif iButton == 1 ; 2 Units player.PlaceAtMe RadioSpawnerAlly 2 elseif iButton == 2 ; 3 Units player.PlaceAtMe RadioSpawnerAlly 3 elseif iButton == 3 ; 4 Units player.PlaceAtMe RadioSpawnerAlly 4 elseif iButton == 4 ; 5 Units player.PlaceAtMe RadioSpawnerAlly 5 elseif iButton == 5 ; 6 Units player.PlaceAtMe RadioSpawnerAlly 6 elseif iButton == 6 ; 7 Units player.PlaceAtMe RadioSpawnerAlly 7 elseif iButton == 7 ; 8 Units player.PlaceAtMe RadioSpawnerAlly 8 endif endif set iGo to 0 End This worked perfectly! I managed to get it working by just using 1 menu but at least now I know how to get 2 to work together, thank you so much! Link to comment Share on other sites More sharing options...
Recommended Posts