danshive Posted June 22, 2011 Share Posted June 22, 2011 I'm designing a custom gun with multiple settings to it, and I want to be able to determine which setting it uses through a global variable that's set by a menu. This menu is called through an ingestable item that replenishes itself after being used. Everything about the gun EXCEPT setting the global variable through a menu works. I can change the global variable using console commands and the gun behaves as it should, but the menu doesn't change anything. This is my first menu, so I assume I'm doing something horribly stupid. The global variable is "GunSettings" ScriptName GunSettingscript int iButton0 Begin ScriptEffectStart ShowMessage GunGSettingMessage ; shows up as it should set iButton0 to GetButtonPressed if iButton0 == -1 ; No button has been pressed yet Return elseif iButton0 == 0 ;Change Nothing elseif iButton0 == 1 set GunSettings to 101 elseif iButton0 == 2 set GunSettings to 201 elseif iButton0 == 3 set GunSettings to 301 elseif iButton0 == 4 set GunSettings to 401 elseif iButton0 == 5 set GunSettings to 501 endif end Any help would be greatly appreciated. Link to comment Share on other sites More sharing options...
rickerhk Posted June 22, 2011 Share Posted June 22, 2011 A scripteffectstart block only runs one frame. So use a gamemode block or a scripteffectupdate for the meat of your script. ScriptName GunSettingscript int iButton0 int iMenuInit Begin ScriptEffectStart set iMenuInit to 0 END Begin ScriptEffectUpdate if (iMenuInit == 2) return endif if (iMenuInit == 0) ShowMessage GunGSettingMessage ; shows up as it should set iMenuInit to 1 endif set iButton0 to GetButtonPressed if iButton0 == -1 ; No button has been pressed yet Return elseif iButton0 == 0 ;Change Nothing set iMenuInit to 2 elseif iButton0 == 1 set GunSettings to 101 set iMenuInit to 2 elseif iButton0 == 2 set GunSettings to 201 set iMenuInit to 2 elseif iButton0 == 3 set GunSettings to 301 set iMenuInit to 2 elseif iButton0 == 4 set GunSettings to 401 set iMenuInit to 2 elseif iButton0 == 5 set GunSettings to 501 set iMenuInit to 2 endif end Link to comment Share on other sites More sharing options...
danshive Posted June 22, 2011 Author Share Posted June 22, 2011 Thank you for your reply, but it doesn't seem to work. I've tried several variations with scripteffectupdate and gamemode blocks, but none of them work right. Whatever the issue is seems to revolve around registering the button value correctly. When debugging, I tried inserting a message, and know that iButton does successfully return -1 in several versions of the script, but won't return anything else. Here was my last failed attempt. It's among the ones that got as far as the -1 return: ScriptName GunSettingscript int iButton int menuappear Begin scripteffectstart set menuappear to 0 End Begin GameMode if menuappear == 0 ShowMessage GunSettingMessage set menuappear to 1 endif set iButton to GetButtonPressed if iButton > -1 if iButton == 0 showmessage GunHasBeenSet elseif iButton == 1 set GunSettings to 101 showmessage GunHasBeenSet elseif iButton == 2 set GunSettings to 201 showmessage GunHasBeenSet elseif iButton == 3 set GunSettings to 301 showmessage GunHasBeenSet elseif iButton == 4 set GunSettings to 401 showmessage GunHasBeenSet elseif iButton == 5 set GunSettings to 501 showmessage GunHasBeenSet endif endif end Link to comment Share on other sites More sharing options...
rickerhk Posted June 23, 2011 Share Posted June 23, 2011 Sorry, I missed the part about using an ingestible.In order to get it to run multiple frames, you have to give the effect inside the ingestible a duration. For this script, I just gave it a duration of 9999. Then the script dispels it when its done. ScriptName GunSettingscript int iButton int menuappear Begin scripteffectupdate if (menuappear == 0) ShowMessage GunSettingMessage set menuappear to 1 elseif (menuappear == 2) player.dispel GunSettingIngestible return endif set iButton to GetButtonPressed if iButton > -1 if iButton == 0 set menuappear to 2 elseif iButton == 1 set GunSettings to 101 set menuappear to 2 elseif iButton == 2 set GunSettings to 201 set menuappear to 2 elseif iButton == 3 set GunSettings to 301 set menuappear to 2 elseif iButton == 4 set GunSettings to 401 set menuappear to 2 elseif iButton == 5 set GunSettings to 501 set menuappear to 2 endif endif end Link to comment Share on other sites More sharing options...
Recommended Posts