Jump to content

Menu in Script


Dwight Darkmoon

Recommended Posts

Hello,

 

I am new to scripting and i am working on a house mod with vending machines. They all work fine exept one with 2 menus. It is a eatotronic vending machine. Everything on the first menu works perfectly. If you hit the button next page on the first menu, it shows the second menu. If you select any item it gets out of the menu . No items or caps added/remove. The geck lets me save my script so it must be something simple that i am missing. If someone could take a look at my script and tell me what is wrong with it. I would be eternaly grateful :)

 

scn 0LHEatOTronicScript
short button
short myState

begin onactivate
   set myState to 1
   showmessage 0LHEatOTronicMessage
end

begin GameMode
   if myState == 1

       set button to GetButtonPressed
       if button > -1
           if button == 0
		if player.GetItemCount caps001 >= 10
		player.removeitem caps001 10
		player.additem BlamcoMacandCheese 1
           else
           showmessage 0LHNotEnoughCaps
           endif

		elseif button == 1
		if player.GetItemCount caps001 >= 2
		player.removeitem caps001 2
		player.additem Bubblegum 1
           else
           showmessage 0LHNotEnoughCaps
           endif
		
           elseif button == 2
		if player.GetItemCount caps001 >= 10
		player.removeitem caps001 10
		player.additem Cram 1
           else
           showmessage 0LHNotEnoughCaps
           endif

           elseif button == 3
		if player.GetItemCount caps001 >= 10
		player.removeitem caps001 10
		player.additem DandyBoyApples 1
		else
           showmessage 0LHNotEnoughCaps
           endif

	    elseif button == 4	
		if player.GetItemCount caps001 >= 10
		player.removeitem caps001 10
		player.additem FancyLadsSnackCakes 1
           else
		showmessage 0LHNotEnoughCaps
           endif

		elseif button == 5
                       set myState to 2
               showmessage 0LHEatOTronicMessage2

           endif
		
		if myState == 2

       set button to GetButtonPressed
       if button > -1
		
		elseif button == 0
		if player.GetItemCount caps001 >= 10
		player.removeitem caps001 10
		player.additem InstaMash 1
           else
           showmessage 0LHNotEnoughCaps
           endif
		
		elseif button == 1
		if player.GetItemCount caps001 >= 10
		player.removeitem caps001 10
		player.additem PorkNBeans 1
           else
           showmessage 0LHNotEnoughCaps
           endif
		
		elseif button == 2
		if player.GetItemCount caps001 >= 10
		player.removeitem caps001 10
		player.additem PotatoCrisps 1
           else
    showmessage 0LHNotEnoughCaps
           endif

		elseif button == 3	
		if player.GetItemCount caps001 >= 10
		player.removeitem caps001 10
		player.additem SalisburySteak 1
           else
    showmessage 0LHNotEnoughCaps
           endif

		elseif button == 4
		if player.GetItemCount caps001 >= 10
		player.removeitem caps001 10
		player.additem SugarBombs01 1
           else
           showmessage 0LHNotEnoughCaps
           endif
		
		elseif button == 5
		set myState to 0
		
           endif
           set myState to 0
       endif




endif
endif


end

 

Thank you

Link to comment
Share on other sites

Well, firstly, please use proper indentation. When code is not indented, it's hard to read, but when it's intended badly, it's even harder to read, because it's confusing. You may try Cipscis' Script Validator (http://www.cipscis.com). By the way, it shows several warning and error messages on your code.

 

Secondly, it seems that your code has this structure:

 

begin GameMode
   if myState == 1
       if button > -1
           ;Do something
           if myState == 2
               ;Do something
           endif
       endif
   endif
end

 

Which means you have put one if-block in a wrong place where it can never execute. Or am I reading it incorrectly?

Link to comment
Share on other sites

Thank you purple pigeon. With the link you gave me i was able to quickly find the information i was looking for.  I was able to put a working (Next Page/Previous Page) button. It wasn't possible the way i made the old script.<div><div><div><br>Thanks again for the link.

 

</div>

 

</div></div>

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...