Game Maker's Garage Forum

Game Creation => SilverCreator => Topic started by: Xiphos on June 26, 2009, 11:23:40 AM

Title: Exception?
Post by: Xiphos on June 26, 2009, 11:23:40 AM
"An exception has occurred.
Stability will decrease."

silvercreator v1.6a9
I put in code in a new method and that's what it says.
The code is 42 lines long. No parameters. No return type.
Title: Re: Exception?
Post by: GMG Hendo on June 26, 2009, 12:09:06 PM
Try downloading SilverCreator 1.6b3. It's much newer and more stable. Here's a mirror for you since the SC site is down.

http://kttns.org/mwu5o
Title: Re: Exception?
Post by: Xiphos on June 26, 2009, 02:31:00 PM
thanks a lot! =)

It still say stability will decrease but works just fine! =)
Title: Re: Exception?
Post by: GMG Hendo on June 26, 2009, 02:58:25 PM
Your welcome :)
Title: Re: Exception?
Post by: GMG Mike on June 26, 2009, 05:20:07 PM
What is the code? I need to know the code and then I can fix the "stability will decrease" error. It is a bug in SilverCreator.
Title: Re: Exception?
Post by: Xiphos on June 26, 2009, 08:23:22 PM
Code: [Select]
IF spritevalid(1) = true THEN
IF mainspacex = 1 THEN
   LET spritex(1) = 0
END IF
IF mainspacex = 2 THEN
   LET spritex(1) = 40
END IF
IF mainspacex = 3 THEN
   LET spritex(1) = 80
END IF
IF mainspacex = 4 THEN
   LET spritex(1) = 120
END IF
IF mainspacex = 5 THEN
   LET spritex(1) = 160
END IF
IF mainspacex = 6 THEN
   LET spritex(1) = 200
END IF
IF mainspacex = 7 THEN
   LET spritex(1) = 240
END IF
IF mainspacey = 1 THEN
   LET spritey(1) = 0
END IF
IF mainspacey = 2 THEN
   LET spritey(1) = 45
END IF
IF mainspacey = 3 THEN
   LET spritey(1) = 90
END IF
IF mainspacey = 4 THEN
   LET spritey(1) = 135
END IF
IF mainspacey = 5 THEN
   LET spritey(1) = 180
END IF
IF mainspacey = 6 THEN
   LET spritey(1) = 225
END IF
IF mainspacey = 7 THEN
   LET spritey(1) = 270
END IF
END IF
Title: Re: Exception?
Post by: HarryCaray on June 26, 2009, 08:39:12 PM
If I'm not mistaken, SPRITEX and SPRITEY aren't assignable. They return values.
Title: Re: Exception?
Post by: GMG Mike on June 26, 2009, 08:42:55 PM
Quote
If I'm not mistaken, SPRITEX and SPRITEY aren't assignable. They return values.


They are assignable. It is a little-known feature. I was actually thinking of removing it.

However, there is one benefit to using the assignment vs MOVESPRITE and it's that you can assign the X and Y individually.

LET SPRITEX(5) = 50

You would need to do this to replicate with movesprite:

MOVESPRITE 5, 50, SPRITEY(5)

However the assignment method does not support adding the extra boolean to suppress the screen update.
Title: Re: Exception?
Post by: Xiphos on June 26, 2009, 08:45:42 PM
EDITTED: Yeah what Mike said...

=)
Title: Re: Exception?
Post by: HarryCaray on June 26, 2009, 08:50:00 PM
I wonder what would happen if you tried to make a SPRITEX array and then tried to assign a value to it.
Title: Re: Exception?
Post by: Xiphos on June 26, 2009, 08:53:15 PM
What's an array???? ???
Title: Re: Exception?
Post by: GMG Mike on June 26, 2009, 08:56:39 PM
Quote
What's an array???? ???

Array is new in SC v1.6b2.

This creates an array:

DIM donald(50)

Basically it creates a number variable with 50 different choices (or any number you want. you pick the number).

PRINT STR$(donald(25))

LET donald(43) = 27
Title: Re: Exception?
Post by: GMG Mike on June 26, 2009, 08:57:27 PM
Quote
I wonder what would happen if you tried to make a SPRITEX array and then tried to assign a value to it.


One will override the other. I don't remember which though.
Title: Re: Exception?
Post by: HarryCaray on June 26, 2009, 08:58:15 PM
Its a variable that can hold more than one value.
Say you have an amount of gold you win after each level of fighting. First you'd create the array

DIM goldAmount(50)

(50) means there are 50 slots within the variable goldAmount, you could use this as each level.

Then you'd assign a value to each slot:

LET goldAmount(1)=10
LET goldAmount(2)=15
LET goldAmount(3)=20
LET goldAmount(4)=25
etc...

So when you beat level one, you get 10 gold, level two, 15 gold and so on.

LET level=3
LET playerGold=playerGold+goldAmount(level)


Whoops, you beat me to it, but I have a question also, how are arrays saved to a file?
Title: Re: Exception?
Post by: Xiphos on June 26, 2009, 09:04:13 PM
Okay I think I understand!
Title: Re: Exception?
Post by: GMG Hendo on June 26, 2009, 09:52:39 PM
Yeah arrays can be confusing at first but they're dead useful when you get a handle on them
Title: Re: Exception?
Post by: GMG Mike on June 26, 2009, 11:03:46 PM
Quote
Whoops, you beat me to it, but I have a question also, how are arrays saved to a file?

You could just write one line with the number of elements using COUNTARRAY and then one item per line.
Title: Re: Exception?
Post by: Xiphos on June 28, 2009, 10:04:09 AM

Quote
Its a variable that can hold more than one value.
Say you have an amount of gold you win after each level of fighting. First you'd create the array
 
DIM goldAmount(50)
 
(50) means there are 50 slots within the variable goldAmount, you could use this as each level.
 
Then you'd assign a value to each slot:
 
LET goldAmount(1)=10
LET goldAmount(2)=15
LET goldAmount(3)=20
LET goldAmount(4)=25
etc...
 
So when you beat level one, you get 10 gold, level two, 15 gold and so on.
 
LET level=3
LET playerGold=playerGold+goldAmount(level)
 
 
Whoops, you beat me to it, but I have a question also, how are arrays saved to a file?

What if you wanted to do the opposite? When you get a certain amount of XP you gain a level?
Title: Re: Exception?
Post by: HarryCaray on June 28, 2009, 10:47:13 AM
Code: [Select]
DIM xpLevel(50)//Just for the example the maximum level is 50
LET xpLevel(1)=0//At level "1", you need at least 0 xp
LET xpLevel(2)=100//At level "2", you need at least 100 xp
LET xpLevel(3)=500
etc...

Then, you'd check the xp every time you gain it.

LET temp=MAX(playerXP, xpLevel(playerLevel+1)//See which is higher, the player's xp or the next xp level
IF temp=xpLevel(playerLevel+1) THEN//This means the player has not reached the next level yet
NOTEALERT "You have not reached the next level as of yet!", "Sorry!"
ELSE
LET playerLevel=playerLevel+1//The player has more xp than the next level, so he gets to gain a level
END IF

I think this should work.
Title: Re: Exception?
Post by: Xiphos on June 28, 2009, 10:59:14 AM
Thanks Harry!!!
Title: Re: Exception?
Post by: Connors on February 23, 2010, 10:47:01 PM
This is cool, I think this might help with a program I was trying to make.
I'm curious, since an array is basically a list of numbers, can you use it to do something to multiple sprites? For example, if you have a list for all the enemies' numbers called enemies and then say CREATESPRITE (enemies) will it make more than one?
Title: Re: Exception?
Post by: Xiphos on February 24, 2010, 07:29:35 AM
Code: [Select]
FOR x = 1 to enemies
IF spritevalid(x)=true THEN
Pushsprite x, -5, 0
END IF
NEXT

Not sure if arrays would but that would push them all.

EDIT: also put a make sure the sprites are valid.
Title: Re: Exception?
Post by: EqwanoX on February 24, 2010, 10:22:42 AM
**arrays allow you to use variables IN a variables name.**

heres an example of what arrays can do, say your doing an rpg with four enemies. without arrays you have to find the specific enemies hp variable to alter when you attack


if attackenemy=1 then let enemyHP1=enemyhp1-damage
if attackenemy=2 then let enemyHP2=enemyhp2-damage
if attackenemy=3 then let enemyHP3=enemyhp3-damage
if attackenemy=4 then let enemyHP4=enemyhp4-damage

with arrays you dont need to find it you just put the variable of the enemy your attacking in the name of the enemy's hp variable to match enemy

let enemyhp(attackenemy)=enemyhp(attackenemy)-damage
Title: Re: Exception?
Post by: Connors on February 24, 2010, 03:41:45 PM
Thanks guys, that clears thigns up a lot. ;D
 BTW, SOMEONE need to post a tutorial on that SC Wiki for these things, it's kind of empty...
Title: Re: Exception?
Post by: Connors on February 26, 2010, 08:26:12 PM
IF spritevalid(x)=true THEN

There's what i was looking for... That's a useful command. XD
(I've been trying to remember where I saw it posted)
Title: Re: Exception?
Post by: EqwanoX on February 27, 2010, 09:49:32 AM
it might be good to download sc 1.5 for syntax explanations, it uses all the same commands