What simple bug am I overlooking?

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

What simple bug am I overlooking?

Post by Willy Elektrix »

This seems really straightforward, but something isn't working and its driving me crazy. Take a look at the script below. This is a (simplified) version of a script in my game.

Essentially, there is a 1/5 chance that the PC finds the "vibro" item. Then there is a 1/5 chance that the PC finds the "adrenal" item instead.

If either item is found, the "rewardnum" becomes 100 or 101. Then a text box should display. However, the script is not working. No matter how many times I run it, the PC never finds the item.

What's going on?

Code: Select all

plotscript, chest1, begin
###Declare variable###
variable (rewardnum)
variable (specialnum)

###chest to find items###
if (check tag (tag:vibro) == off) then ( 
	specialnum := random (1,5)
	if (specialnum == 1) then (rewardnum := 100)
) if (check tag (tag:adrenal) == off) then (
	specialnum := random (1,5)
	if (specialnum == 1) then (rewardnum := 101) 
)

###items find###
) if (rewardnum == 100) then (
	show text box (850)
	get item (item:vibro, 1)
	set default weapon (0,item:vibro)
) else if (rewardnum == 101) then (
	show text box (1000)
	set default weapon (0,item:adrenal)
	force equip (0,slot:head,item:adrenal)
	get item (item:adrenal, 1)
)

end
User avatar
Gizmog
Metal King Slime
Posts: 2622
Joined: Tue Feb 19, 2008 5:41 am

Re: What simple bug am I overlooking?

Post by Gizmog »

[quote="Willy Elektrix"]

Code: Select all

###items find###
) if (rewardnum == 100) then (
code][/quote]

I think the problem is right there. That ) is extra, and might be ending the whole script before it gets to the rest of the stuff.

EDIT: Tried to compile it that way and it wouldn't compile... could it be that the ForceEquip is throwing you? The item appearing in the hero's equipment rather than on the inventory screen? Other than that, I'm totally lost.
Last edited by Gizmog on Sat Nov 21, 2015 3:28 am, edited 1 time in total.
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

There's a second error: ") if (check tag (tag:adrenal) == off) then ( " should be ") else if (check tag (tag:adrenal) == off) then ( "
User avatar
Willy Elektrix
Liquid Metal Slime
Posts: 910
Joined: Sun Aug 15, 2010 11:30 pm

Post by Willy Elektrix »

I made this way too confusing for you guys. I tried to edit out the parts of the script that had nothing to do what I was trying to explain. The actual script about 100 lines long.

However, in doing so, I edited out the part where the error actually was. I found the bug while I was trying to figure out a response to you. So, inadvertently, you helped me after all.

Thanks!
Post Reply