Jump to content

Create Item Script Not Working


Recommended Posts

If this sort of thing has been asked and answered, I couldn't find it, so links to such an answer would definitely be appreciated! I have sorted through every "Oblivion Scripting Tutorial" known to humankind (here, as well as TESAlliance, TESNexus, TESCSWiki, and others, looking for instructions as to how to make this work.) (It's depressing how many links are now "Page Not Found" and "Domain for Sale")

I can do this sort of thing for Skyrim, but for the life of me, I can't seem to do it (or remember how to do it, actually) for Oblivion. The Construction Set saves the script with no warnings or exceptions, so I thought the script worked. But it doesn't.

When the player clicks the Drinks Pitcher (an activator) it should pop a message : "What do you want to make?" "Cider, Grape Juice, Nothing"
It DOES that.

If you pick "Cider", it should find out if you have 2 apples + 1 Firesalt. If you do, it should remove them from your inventory and add Cider. If you don't, it should say "You don't have the stuff for that."
It does NOT do that.

If you pick "Grape Juice" it should find out if you have 2 grapes + 1 Frostsalt. If you do, it should remove them from your inventory and add Grape Juice. If you don't, it should say "You don't have the stuff for that."
It does NOT do that.

It also never allows the Drinks Pitcher Menu to display again.

I made the Drinks Pitcher Activator; I made the Cider; I made the Grape Juice. At the moment, the pitcher, a bunch of apples, grapes, firesalts, and frostsalts, are all sitting on a table in an otherwise empty test cell. I play-tested this with only Ob and SI loaded (well and OBSE) so I know there's no mod conflicts or anything. The trouble, I am positive, is my script -- Even though the Construction Set saved and compiled it with no problem.



This is the script:

 

 

 

ScriptName AllaDrinkScript

Short Choosing
Short Choice

Begin OnActivate
   Set Choosing to -1
     MessageBox "What do you want to make?", "Cider", "Grape Juice", "Nothing"
     Set Choosing to 1
     Set Choice to -1
End

Begin GameMode
   If (Choosing == 1)

     	If (Choice == -1) ;No choice yet
        	Set Choice to GetButtonPressed

		ElseIf (Choice == 0) ;Cider   
        		If (Player.GetItemCount Apple >= 2, Player.GetItemCount FireSalts >= 1)
             		   Player.RemoveItem Apple 2
             		   Player.RemoveItem FireSalts 1
             		   Player.AddItem AllaDrinkCider 1
        		ElseIf (Player.GetItemCount Apple < 2 Player.GetItemCount FireSalts < 1)
             		   MessageBox "You don't have the stuff for that."
			EndIf

		ElseIf (Choice == 1) ;Grape Juice   
        		If (Player.GetItemCount Grapes >= 2, Player.GetItemCount FrostSalts  >= 1)
             		   Player.RemoveItem Grapes 2
             		   Player.RemoveItem FrostSalts 1
             		   Player.AddItem AllaDrinkGrapeJuice 1
        		ElseIf (Player.GetItemCount Grapes < 2 Player.GetItemCount FrostSalts < 1)
             		   MessageBox "You don't have the stuff for that."
			EndIf
	EndIf

     	EndIf ;Choice block end

   EndIf ;Choosing block end

End ;GameMode end

 


Any advice, corrections, suggestions, or even commiseration would be more than welcome! Thanks

Link to comment
Share on other sites

These conditions looks weird to me, I would suggest using rather this:

if player.GetItemCount Apple >= 2 && player.GetItemCount FireSalts >= 1 ;and
....
elseif player.GetItemCount Apple < 2 || player.GetItemCount FireSalts < 1 ;or
....
endif

I also think that plain else would be enough.

And for choice:

set choice to GetButtonPressed
if choice == 0
....
elseif choice == 1
....
endif
Link to comment
Share on other sites

As far as I can see, I cannpt see any problems with your script really. You must add more debug info to your self in all of your choices. When you add an item to your self, you need to use the BaseID, not the ReferenceItem nor RefID as you will add a new item into the game, from a database with BaseID.

 

To make the script more fancy, exchange MessageBox with MessageBoxEX from OBSE and type:

MessageBoxEX "What do you want to make?Cider|Grape Juice|Nothing"

But then it will have OBSE as a requirement. ;)

 

CSE, will show you row numbers that you will get from the consol in game if an error in a script shows up and it is the Ofset number which is extremely useful when you debug stuff. I also made a short tutorial at this forum how to make ENB and CSE to work together if you need to know that.

Link to comment
Share on other sites

Thank you Roman and Pellape! I'll get back to work, with your advice.

 

Also, Pell -- I use Notepad++, it shows line numbers, but I will definitely look up your tutorial, too. Everything helps!

 

Having OBSE as a requirement doesn't bother me. My kids (oh lord my thirty-year old kids... I am old!) basically use the same setup that I do, so they use OBSE anyway.

 

EDIT OMG YOU GUYS ARE AWESOME!

It worked! It worked, it worked it worked!

 

Thank you both so MUCH!

Edited by Allannaa
Link to comment
Share on other sites

And here is also working example for menu:

scn ActivateMenuScript

short choice
short menu
short init

begin OnActivate player
   MessageBox "What do you want to make?","Cider","Brandy","Nothing"
   set menu to 1
end

begin GameMode
   if init == 0
     set choice to -1
     set init to 1
   endif
   if menu != 0
     set choice to GetButtonPressed
     if choice != -1
	if choice == 0
	   print "You selected Cider."
        elseif choice == 1
	   print "You selected Brandy."
	elseif choice == 2
	   print "You don't want to make anything."
	endif
	set menu to 0
	set choice to -1
     endif				
   endif
end

This will print into console your choice.

Edited by RomanR
Link to comment
Share on other sites

  • Recently Browsing   0 members

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