Choices in scripting

Post » Wed Feb 16, 2011 9:03 pm

So I'm making this gem inspection kit for a mod. It's supposed to have a small chance, based on the player's Mercantile, to increase the value of gems a tiny bit. I made a test script; it should say that I have none of the selected type of gem, but for some reason doesn't work. It's a problem with the Messagebox choices, I'm sure. Can anyone help me out?

Here's the script:
ScriptName Z13InKit01ScriptShort GemTypeShort UsedBegin OnEquip	Messagebox "Choose a type of gem to inspect:", "Flawed Pearl", "Flawed Topaz", "Flawed Ruby", "Flawed Sapphire", "Flawed Emerald", "Flawed Diamond"	Set Used to 1EndBegin GameMode	If Used >= 1		Set GemType to GetButtonPressed	If GemType == 1		MessageBox "You don't have any flawed pearls."	endif		If GemType == 2 		Messagebox "You don't have any flawed topaz."	endif	If GemType == 3		MessageBox "You don't have any flawed ruby."	endif	If GemType == 4		MessageBox "You don't have any flawed sapphire."	endif	If GemType == 5		MessageBox "You don't have any flawed emerald."	endif	If GemType == 1		MessageBox "You don't have any flawed diamond."	endifendifEnd

User avatar
Jessie Rae Brouillette
 
Posts: 3469
Joined: Mon Dec 11, 2006 9:50 am

Post » Thu Feb 17, 2011 12:44 am

So I'm making this gem inspection kit for a mod. It's supposed to have a small chance, based on the player's Mercantile, to increase the value of gems a tiny bit. I made a test script; it should say that I have none of the selected type of gem, but for some reason doesn't work. It's a problem with the Messagebox choices, I'm sure. Can anyone help me out?

Here's the script:
Spoiler
ScriptName Z13InKit01ScriptShort GemTypeShort UsedBegin OnEquip	Messagebox "Choose a type of gem to inspect:", "Flawed Pearl", "Flawed Topaz", "Flawed Ruby", "Flawed Sapphire", "Flawed Emerald", "Flawed Diamond"	Set Used to 1EndBegin GameMode	If Used >= 1		Set GemType to GetButtonPressed	If GemType == 1		MessageBox "You don't have any flawed pearls."	endif		If GemType == 2 		Messagebox "You don't have any flawed topaz."	endif	If GemType == 3		MessageBox "You don't have any flawed ruby."	endif	If GemType == 4		MessageBox "You don't have any flawed sapphire."	endif	If GemType == 5		MessageBox "You don't have any flawed emerald."	endif	If GemType == 1		MessageBox "You don't have any flawed diamond."	endifendifEnd


I'm not sure, but IIRC, in case multiple if-blocks are used in a row, it should not be a single block at a time (if something == * endif)...
Try this:
Spoiler
ScriptName Z13InKit01ScriptShort GemTypeShort UsedBegin OnEquip	Messagebox "Choose a type of gem to inspect:", "Flawed Pearl", "Flawed Topaz", "Flawed Ruby", "Flawed Sapphire", "Flawed Emerald", "Flawed Diamond"	Set Used to 1EndBegin GameMode   If Used >= 1	   Set GemType to GetButtonPressed	If GemType == 1		MessageBox "You don't have any flawed pearls."			elseif GemType == 2 		Messagebox "You don't have any flawed topaz."		elseif GemType == 3		MessageBox "You don't have any flawed ruby."		elseif GemType == 4		MessageBox "You don't have any flawed sapphire."		elseif GemType == 5		MessageBox "You don't have any flawed emerald."		elseif GemType == 1		MessageBox "You don't have any flawed diamond."	   endifEnd

User avatar
Nathan Barker
 
Posts: 3554
Joined: Sun Jun 10, 2007 5:55 am

Post » Thu Feb 17, 2011 6:19 am

[/spoiler]
I'm not sure, but IIRC, in case multiple if-blocks are used in a row, it should not be a single block at a time (if something == * endif)...
Try this:
Spoiler
ScriptName Z13InKit01ScriptShort GemTypeShort UsedBegin OnEquip	Messagebox "Choose a type of gem to inspect:", "Flawed Pearl", "Flawed Topaz", "Flawed Ruby", "Flawed Sapphire", "Flawed Emerald", "Flawed Diamond"	Set Used to 1EndBegin GameMode   If Used >= 1	   Set GemType to GetButtonPressed	If GemType == 1		MessageBox "You don't have any flawed pearls."			elseif GemType == 2 		Messagebox "You don't have any flawed topaz."		elseif GemType == 3		MessageBox "You don't have any flawed ruby."		elseif GemType == 4		MessageBox "You don't have any flawed sapphire."		elseif GemType == 5		MessageBox "You don't have any flawed emerald."		elseif GemType == 1		MessageBox "You don't have any flawed diamond."	   endifEnd


It's still not saying anything. I'm starting to think it might be the fact that I'm trying to equip it, and it's a misc. item (modified tongs). I did get it to say the proper message after a second equip, but I appear to have lost the code for that...
User avatar
Liv Staff
 
Posts: 3473
Joined: Wed Oct 25, 2006 10:51 pm

Post » Thu Feb 17, 2011 2:56 am

It's still not saying anything. I'm starting to think it might be the fact that I'm trying to equip it, and it's a misc. item (modified tongs). I did get it to say the proper message after a second equip, but I appear to have lost the code for that...

Equip tongs? :D That's new. I'll see if I can find something.

New information: I have scouted through some mods which I know to use OnEquip with misc. items. However, it seems that the player ought to exit the menu, and a custom-made menu should appear. The custom menu needs some pretty scripting, but other than that I don't know if it is possible to make weird OnEquip pop-ups...
User avatar
Samantha hulme
 
Posts: 3373
Joined: Wed Jun 21, 2006 4:22 pm

Post » Thu Feb 17, 2011 4:40 am

Equip tongs? :D That's new. I'll see if I can find something.

New information: I have scouted through some mods which I know to use OnEquip with misc. items. However, it seems that the player ought to exit the menu, and a custom-made menu should appear. The custom menu needs some pretty scripting, but other than that I don't know if it is possible to make weird OnEquip pop-ups...


:( But I am lazy.

What do you mean by "weird OnEquip pop-ups"? Cause if you mean OnEquip for misc. items, OnActivate for a world object is a viable option for me.

As for the tongs, well, they seemed like a good option for holding gems. And I couldn't find a magnifying glass or similar icon, and I'm too lazy to make my own icon :D (plus I don't have BSA unpackers or anything.)
User avatar
Alyce Argabright
 
Posts: 3403
Joined: Mon Aug 20, 2007 8:11 pm

Post » Thu Feb 17, 2011 12:30 am

:( But I am lazy.

What do you mean by "weird OnEquip pop-ups"? Cause if you mean OnEquip for misc. items, OnActivate for a world object is a viable option for me.

As for the tongs, well, they seemed like a good option for holding gems. And I couldn't find a magnifying glass or similar icon, and I'm too lazy to make my own icon :D (plus I don't have BSA unpackers or anything.)

By the pop-ups I just mean a menu that pops out :D
User avatar
steve brewin
 
Posts: 3411
Joined: Thu Jun 21, 2007 7:17 am

Post » Thu Feb 17, 2011 4:30 am

By the pop-ups I just mean a menu that pops out :D

Oh. :facepalm:

Well, I'm still not sure why it doesn't say anything after I press one of the buttons, or why I need to equip the kit a second time...
User avatar
Budgie
 
Posts: 3518
Joined: Sat Oct 14, 2006 2:26 pm

Post » Thu Feb 17, 2011 5:46 am

Oh. :facepalm:

Well, I'm still not sure why it doesn't say anything after I press one of the buttons, or why I need to equip the kit a second time...

Odd indeed...
User avatar
Amanda savory
 
Posts: 3332
Joined: Mon Nov 27, 2006 10:37 am

Post » Thu Feb 17, 2011 1:35 am

Now I applied the same script with an OnActivate block instead of OnEquip and it works like a charm...of course, it has to be a world object instead of item now, since it's OnActivate. Huh.
User avatar
Beth Belcher
 
Posts: 3393
Joined: Tue Jun 13, 2006 1:39 pm

Post » Wed Feb 16, 2011 9:43 pm

Well for one thing, the button array index starts at 0... Another thing is you haven't constructed your if block properly... Have a look at this http://cs.elderscrolls.com/constwiki/index.php/MessageBox_Tutorial

Edit: just saw your post - I thought the scripting language wanted the parens - that's convention anyway...
User avatar
D LOpez
 
Posts: 3434
Joined: Sat Aug 25, 2007 12:30 pm

Post » Thu Feb 17, 2011 8:16 am

Just a minor note about messageboxes; the first option is , the second is 1, and so on. You should fix that, but unless you only ever tried the "Flawed Pearl" option in your tests, that's not the main problem.
User avatar
Nuno Castro
 
Posts: 3414
Joined: Sat Oct 13, 2007 1:40 am

Post » Thu Feb 17, 2011 5:39 am

Just a minor note about messageboxes; the first option is , the second is 1, and so on. You should fix that, but unless you only ever tried the "Flawed Pearl" option in your tests, that's not the main problem.

I don't know, it's working now that I switched to a world object. I tried everything before...I just don't know.

Quick question, how does one declare a random variable? I'm designing it so that the chances of getting an improved gem are 25 in 250. For every other level the player has in mercantile, the allowed range of variables (1-25) goes up by a maximum of one and the random factor goes down by one. So your odds can be anywhere from 25/250 to 75/100.
User avatar
Mark Churchman
 
Posts: 3363
Joined: Sun Aug 05, 2007 5:58 am

Post » Thu Feb 17, 2011 3:54 am

I don't know, it's working now that I switched to a world object. I tried everything before...I just don't know.

Quick question, how does one declare a random variable? I'm designing it so that the chances of getting an improved gem are 25 in 250. For every other level the player has in mercantile, the allowed range of variables (1-25) goes up by a maximum of one and the random factor goes down by one. So your odds can be anywhere from 25/250 to 75/100.

Crap, won't let me edit my last one.

Anyways, that should be random factor goes down by TWO...sorry about that...

EDIT: I svck at math. Okay, so every single mercantile level counts for the maximum range going down...so it goes from 250 to 150 over the levels. Every OTHER level counts for the success range, so it goes from 25 to 75. At level 100 Mercantile, your odds are 75/150...I'm not sure what exactly I was doing before...

EDIT 2: And is there a way to make a random value above 100 without using the OBSE?
User avatar
neil slattery
 
Posts: 3358
Joined: Wed May 16, 2007 4:57 am


Return to IV - Oblivion