Gamer921 Posted April 11, 2017 Share Posted April 11, 2017 I created a mod which contains this script on one of the activators.While it works as long as i dont try to use the menus more than once. Im curious on how to fix that issue so that i can loop the two menus if i wanted and my buttons still work as intended. What have i done wrong with this script heres the source script Message Property XN0XMenu1 autoMessage Property XN0XStats1 autoEvent OnActivate(ObjectReference AkActionRef) Int Button = XN0XMenu1.Show() If Button == 0 ;Stats Messagebox Int Buttons = XN0XStats1.Show() if Buttons == 0 ;Add CarryWeight Game.GetPlayer().ModActorValue("Carryweight",1000) Elseif Buttons == 1 ;Add health Game.GetPlayer().ModActorValue("Health", 100) Elseif Buttons == 2 ;Go Back Button = XN0XMenu1.Show() Elseif Buttons == 3 ; Close Menu endif Elseif Button == 1 EndifEndEvent Link to comment Share on other sites More sharing options...
ReDragon2013 Posted April 11, 2017 Share Posted April 11, 2017 (edited) You have posted your issue in wrong area, CK would be a better choice. What did you posted is a part of the source.Maybe the next source script is helpful. Nevertheless I dislike cheating. XNSelectorScript Scriptname XNSelectorScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/5529737-what-is-wrong-with-this-script/ ; troubleshooting ; "it works as long as i do not try to use the menus more than once." Message PROPERTY msg_menu auto ; XN0XMenu1 Message PROPERTY msg_stats1 auto ; XN0XStats1 ; -- EVENTs -- 1 + "Busy" EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not the player, do nothing ENDIF ;--------------------- gotoState("Busy") ; ### STATE ### ; Make your choice! ; ~~~~~~~~~~~~~~~~~ ; 0=[Stats1] 1=[Cancel] ; we assume two buttons in main menu int i = 0 ; i = Button WHILE (i < 1) && self.GetBaseObject() ; almost right is "cancel" button /and/ make sure you can leave this loop all time i = msg_Menu.Show() IF (i == 0) ; almost left button used i = myF_CheatMenu(akActionRef as Actor) ENDIF ENDWHILE gotoState("") ; ### STATE ### go back to no state ENDEVENT ;========================== state Busy ; I am busy while using menu! ;========= EVENT OnActivate(ObjectReference akActionRef) ENDEVENT ;======= endState ; -- FUNCTION -- Int FUNCTION myF_CheatMenu(Actor aRef) ;------------------------------------- ; http://www.creationkit.com/index.php?title=ModActorValue_-_Actor int i = msg_Stats1.Show() IF (i == 0) aRef.ModActorValue("Carryweight", 250) ; add CarryWeight by 250 RETURN 0 ENDIF IF (i == 1) aRef.ModActorValue("Health", 100) ; add Health by 100 RETURN 0 ENDIF IF (i == 2) RETURN 0 ; - STOP - do nothing, but go back to main ENDIF ;IF (i == 3) RETURN 1 ; - STOP - close all ;ENDIF ENDFUNCTION Edited April 11, 2017 by ReDragon2013 Link to comment Share on other sites More sharing options...
Gamer921 Posted April 11, 2017 Author Share Posted April 11, 2017 (edited) You have posted your issue in wrong area, CK would be a better choice. What did you posted is a part of the source.Maybe the next source script is helpful. Nevertheless I dislike cheating. XNSelectorScript Scriptname XNSelectorScript extends ObjectReference ; https://forums.nexusmods.com/index.php?/topic/5529737-what-is-wrong-with-this-script/ ; troubleshooting ; "it works as long as i do not try to use the menus more than once." Message PROPERTY msg_menu auto ; XN0XMenu1 Message PROPERTY msg_stats1 auto ; XN0XStats1 ; -- EVENTs -- 1 + "Busy" EVENT OnActivate(ObjectReference akActionRef) IF (akActionRef == Game.GetPlayer() as ObjectReference) ELSE RETURN ; - STOP - not the player, do nothing ENDIF ;--------------------- gotoState("Busy") ; ### STATE ### ; Make your choice! ; ~~~~~~~~~~~~~~~~~ ; 0=[Stats1] 1=[Cancel] ; we assume two buttons in main menu int i = 0 ; i = Button WHILE (i < 1) && self.GetBaseObject() ; almost right is "cancel" button /and/ make sure you can leave this loop all time i = msg_Menu.Show() IF (i == 0) ; almost left button used i = myF_CheatMenu(akActionRef as Actor) ENDIF ENDWHILE gotoState("") ; ### STATE ### go back to no state ENDEVENT ;========================== state Busy ; I am busy while using menu! ;========= EVENT OnActivate(ObjectReference akActionRef) ENDEVENT ;======= endState ; -- FUNCTION -- Int FUNCTION myF_CheatMenu(Actor aRef) ;------------------------------------- ; http://www.creationkit.com/index.php?title=ModActorValue_-_Actor int i = msg_Stats1.Show() IF (i == 0) aRef.ModActorValue("Carryweight", 250) ; add CarryWeight by 250 RETURN 0 ENDIF IF (i == 1) aRef.ModActorValue("Health", 100) ; add Health by 100 RETURN 0 ENDIF IF (i == 2) RETURN 0 ; - STOP - do nothing, but go back to main ENDIF ;IF (i == 3) RETURN 1 ; - STOP - close all ;ENDIF ENDFUNCTION To explain my intentions is not so much Cheating but to get familiar with Menu with submenu scripts so that i can finish my mod for a teleporter. So im guessing that the issue im having with my current script is that I didnt create a state or do i need a while command with a bool? Edited April 11, 2017 by Gamer921 Link to comment Share on other sites More sharing options...
ReDragon2013 Posted April 11, 2017 Share Posted April 11, 2017 I provided you a nice working menu script, written along the content as you posted. You ask me: "do i need a while command with a bool?" Without a while loop you cannot come back from "stats menu" to the "main menu", very simple!"with a bool" no idea what did you mean, I only use variables of type Int within the script. Link to comment Share on other sites More sharing options...
cdcooley Posted April 11, 2017 Share Posted April 11, 2017 Here's how I generally handle menus and sub-menus. I like to create a function specific to showing each menu and its options. I find it easier to handle them one at a time and it also means I don't need to track some boolean state and can simply return when the menu should close. Event OnActivate(ObjectReference AkActionRef) ShowMainMenu() EndEvent Function ShowMainMenu() while (true) int choice = XN0XMenu1.Show() if choice == 0 ;Stats Messagebox ShowSubMenu() ; elseif choice == 1 ; other options can go here ; take action or show other menu here else ; quit option return endif endwhile EndFunction Function ShowSubMenu() while (true) ; simply remove the while loop part if you want a menu that does not repeat itself int choice = XN0XStats1.Show() if choice == 0 ; Add CarryWeight Game.GetPlayer().ModActorValue("CarryWeight", 1000) elseif choice == 1 ; Add health Game.GetPlayer().ModActorValue("Health", 100) else ; Go Back return endif endwhile EndFunction That doesn't have an option to leave the entire menu scheme from the sub-menu so you would need to choose "Go Back" from the stats menu the "Quit" from the main menu. If you want the "Close Menu" option to work from the stats menu you need something like this where the sub-menu can return a status to let the main menu know where it should quit too. Event OnActivate(ObjectReference AkActionRef) ShowMainMenu() EndEvent Function ShowMainMenu() while (true) int choice = XN0XMenu1.Show() if choice == 0 ; Stats Messagebox if ShowSubMenu() return endif else ; quit option return endif endwhile EndFunction bool Function ShowSubMenu() while (true) int choice = XN0XStats1.Show() if choice == 0 ; Add CarryWeight Game.GetPlayer().ModActorValue("CarryWeight", 1000) elseif choice == 1 ; Add health Game.GetPlayer().ModActorValue("Health", 100) elseif choice == 2 ; Go Back return false ; false means the outer menu should show itself again else ;if choice == 3 ; Close Menu return true endif endwhile EndFunction Link to comment Share on other sites More sharing options...
LooseEnds Posted April 14, 2017 Share Posted April 14, 2017 Have a look at Darkfox127 SCRIPTMENU video part of his scripting series. Great tutorials. I've adapted a number of his scripts for use in a few mods I've created for myself. I've got a menu script for a teleport trigger, walk into the trigger area an menu pops up offering you different locations to port too. Go have a look at Darkfox127 scripting series it will save you a lot of headaches. You have to enjoy watching endless YouTube adds but the wait is worth it. Link to comment Share on other sites More sharing options...
Gamer921 Posted April 15, 2017 Author Share Posted April 15, 2017 Thanks all for your help i figured out a different way to do this. Turns out i dont need the gotostate stuff or the while code. I just got done with the teleportation script and managed to put together a mark and recall sytem fused in with it. Thanks again. Link to comment Share on other sites More sharing options...
Recommended Posts