Yet another odd script

Post » Fri Oct 15, 2010 1:04 am

Hey guys, this is my first try on a multilevel script, but as soon as i select humans a billion soldiers pop out of nowhere and crash the game. Any ideas?

SCN aaaMenuScript         Short button1           short button2         short  button3       short menulevel     short DoOnceBegin ScriptEffectUpdate     if menulevel == 0&& doOnce == 0      ShowMessage aaaIntro        set button1 to getbuttonpressed set DoOnce to 1endif If button1 == 0            showmessage aaa1stmenu           set menulevel to 1 elseif button1 == 1               showmessage aaa2ndmenu               set menulevel to 2 elseif button1 == 2              player.additem aaacontroller 1           set menulevel to 4 endifIf menulevel == 1set button2 to getbuttonpressedendifIf button2 == 0player.placeatme aaa1stmenu0 3 120 1player.additem aaacontroller 1elseIf button2 == 1player.placeatme aaa1stmenu1 3 120 1player.additem aaacontroller 1elseIf button2 == 2player.placeatme aaa1stmenu2 3 120 1player.additem aaacontroller 1elseIf button3 == 3player.placeatme aaa1stmenu3 1 120 1player.additem aaacontroller 1elseIf button3 == 4player.additem aaacontroller 1set menulevel to 4endifIf menulevel == 2set button3 to getbuttonpressedendifelseIf button3 == 0;player.placeatme aaa2ndmenu0 3 120 1player.additem aaacontroller 1elseIf button3 == 1;player.placeatme aaa2ndmenu1 3 120 1player.additem aaacontroller 1elseIf button3 == 2;player.placeatme aaa2ndmenu2 2 120 1player.additem aaacontroller 1elseIf button3 == 3;player.placeatme aaa2ndmenu3 1 120 1player.additem aaacontroller 1elseIf button3 == 4player.additem aaacontroller 1set menulevel to 4endifend


THe reason for the ; is i havent made those units yet.
User avatar
Nick Tyler
 
Posts: 3437
Joined: Thu Aug 30, 2007 8:57 am

Post » Fri Oct 15, 2010 2:26 am

It's the way you are calling getbuttonpressed. Since button1, button2, and button3 all start out as 0 your script is spawning those actors as soon as it runs, then each successive frame. You should wrap your control variables into the same section as the buttons like so...

if var == 1   set button to getbuttonpressed  if button == 1   ;do stuff  elseif button == 2   ;do stuffendifendif


Placing the endif at the end like this prevents it from checking button until button has been set properly.
User avatar
Music Show
 
Posts: 3512
Joined: Sun Sep 09, 2007 10:53 am

Post » Thu Oct 14, 2010 10:42 pm

It's the way you are calling getbuttonpressed. Since button1, button2, and button3 all start out as 0 your script is spawning those actors as soon as it runs, then each successive frame. You should wrap your control variables into the same section as the buttons like so...

if var == 1   set button to getbuttonpressed  if button == 1   ;do stuff  elseif button == 2   ;do stuffendifendif


Placing the endif at the end like this prevents it from checking button until button has been set properly.



Ok, ive tried that and i have stopped the spawning troops, but now the menu doesnt show with this revised script, and i gain so many near-wieghtless controllers i get over encumbered. Sorry to have to bug poeple for this but ive never tried a multi-stage menu.

SCN aaaMenuScript         Short button1           short button2         short  button3       short menulevel     short DoOnceBegin ScriptEffectUpdate     if menulevel == 0&& doOnce == 0      ShowMessage aaaIntro        set button1 to getbuttonpressed set DoOnce to 1 If button1 == 0                       set menulevel to 1 elseif button1 == 1                              set menulevel to 2 elseif button1 == 2              player.additem aaacontroller 1           set menulevel to 4 endifendifIf menulevel == 1set button2 to getbuttonpressedshowmessage aaa1stmenuIf button2 == 0player.placeatme aaa1stmenu0 3 120 1player.additem aaacontroller 1elseIf button2 == 1player.placeatme aaa1stmenu1 3 120 1player.additem aaacontroller 1elseIf button2 == 2player.placeatme aaa1stmenu2 3 120 1player.additem aaacontroller 1elseIf button3 == 3player.placeatme aaa1stmenu3 1 120 1player.additem aaacontroller 1elseIf button3 == 4player.additem aaacontroller 1set menulevel to 4endifendifIf menulevel == 2set button3 to getbuttonpressedshowmessage aaa2ndmenuelseIf button3 == 0;player.placeatme aaa2ndmenu0 3 120 1player.additem aaacontroller 1elseIf button3 == 1;player.placeatme aaa2ndmenu1 3 120 1player.additem aaacontroller 1elseIf button3 == 2;player.placeatme aaa2ndmenu2 2 120 1player.additem aaacontroller 1elseIf button3 == 3;player.placeatme aaa2ndmenu3 1 120 1player.additem aaacontroller 1elseIf button3 == 4player.additem aaacontroller 1set menulevel to 4endifendifend

User avatar
Donald Richards
 
Posts: 3378
Joined: Sat Jun 30, 2007 3:59 am

Post » Thu Oct 14, 2010 11:46 pm

There's an error in the menulevel 2 block, elseIf button3 == 0 should be if button3 == 0. It's also a good practice to get into setting your control variable back to 0 to prevent the script from processing conditions it doesn't need to.

If button2 == 0

player.placeatme aaa1stmenu0 3 120 1
player.additem aaacontroller 1
set menulevel1 to 0

No space in the following line may be messing things up too.

if menulevel == 0&& doOnce == 0


0 and && have no seperation.
User avatar
Gill Mackin
 
Posts: 3384
Joined: Sat Dec 16, 2006 9:58 pm


Return to Fallout 3