Game Maker's Garage Forum

Game Creation => SilverCreator => Topic started by: Johna100 on February 03, 2013, 06:52:57 PM

Title: Arrays in Silver Creator
Post by: Johna100 on February 03, 2013, 06:52:57 PM
Im working on a game in Silver Creator that uses Arrays. I can't get the arrays to work. When I use a string array it says that string arrays are not supported. Also I was wondering how to use the data from the array once it is set. And I would like to know how to let a variable decide what piece of data is selected. And final if you have some example code of arrays being used properly that would be good. Thanks.

EDIT: Here is how I use arrays in SilverCreator v2.0b3.1

Code: [Select]
// ARRAY
DIM arrayOne(5)
DIM stringArray$(3)

// SET THE VALUE
LET arrayOne(1) = 7
LET stringArray$(1) = "Silver Creator Rocks"

// VIEW ARRAY VALUE
PRINT STR$(arrayOne(1))
PRINT stringArray$(1)
Title: Re: Arrays in Silver Creator
Post by: Gan on February 03, 2013, 07:42:49 PM
I'm looking into it. It's been a while since I coded in Sc and the documentation could use some work.
Title: Re: Arrays in Silver Creator
Post by: Johna100 on February 03, 2013, 07:44:50 PM
Thanks. Im using v1.6b3

EDIT: Im now using SilverCreator v2.0b3.1
Title: Re: Arrays in Silver Creator
Post by: Gan on February 03, 2013, 08:48:09 PM
Ah! You must use the unofficial latest SilverCreator release. I've attached it to this post.

Here we go:
Code: [Select]
DIM myArray$(0)  //Create the array
//Now fill it with greatness
APPENDARRAY myArray$, "We're no strangers to love"
APPENDARRAY myArray$, "You know the rules and so do I"
APPENDARRAY myArray$, "A full commitment's what I'm thinking of"
APPENDARRAY myArray$, "You wouldn't get this from any other guy"
APPENDARRAY myArray$, " "
APPENDARRAY myArray$, "I just wanna tell you how I'm feeling"
APPENDARRAY myArray$, "Gotta make you understand"
APPENDARRAY myArray$, " "
APPENDARRAY myArray$, "Never gonna give you up"
APPENDARRAY myArray$, "Never gonna let you down"
APPENDARRAY myArray$, "Never gonna let you down, Never gonna run around and desert you"
APPENDARRAY myArray$, "Never gonna make you cry"
APPENDARRAY myArray$, "Never gonna say goodbye"
APPENDARRAY myArray$, "Never gonna tell a lie and hurt you"
//Now loop over what's in it
FOR i = 1 to COUNTARRAY(myArray$)
   //Print off the greatness
   PRINT STR$(i) + " " + myArray$(i)
NEXT

//Cheat sheet
// - DIM myArray$(0) // Creates a string array with 0 items
// - COUNTARRAY(myArray$) : Gets the length of the array
// - myArray$(i) : Gets the stuff out of the array as index i
// - APPENDARRAY myArray$, "Stuff" : Adds a string into the array
// - STR$(i) : Converts a number to a string
// Hint: $ at the end of the variable means it is a string variable

Hope that satisfied what you need! And welcome to the GMG!  ;D
Title: Re: Arrays in Silver Creator
Post by: Johna100 on February 03, 2013, 09:39:25 PM
Thank you for your time and help.
Title: Re: Arrays in Silver Creator
Post by: Connors on February 04, 2013, 01:08:06 PM
Good to see new members here, may I ask what you're trying to make?
Title: Re: Arrays in Silver Creator
Post by: Johna100 on February 04, 2013, 05:11:05 PM
Im making a text based RPG and I needed arrays for the weapon equip system.
Title: Re: Arrays in Silver Creator
Post by: GMG Kurt on February 27, 2013, 10:06:51 PM
Keep us updated. I've been so busy with school and debate that I haven't been able to program in forever. Looking at someone elses programming is the next best thing though  ;D
Title: Re: Arrays in Silver Creator
Post by: Johna100 on May 26, 2013, 03:56:43 PM
I have a topic titled DungeonRealms game progress that I will use to post updates.
Title: Re: Arrays in Silver Creator
Post by: Connors on July 25, 2018, 10:09:28 AM
Woah, nice necro. I've never seen someone pick out a support question from 5 years ago. I check this site sometimes but I didn't expect to see a new user!

 Weird, this thread was up when I was barely out of high school.
Title: Re: Arrays in Silver Creator
Post by: Gan on September 09, 2018, 10:24:35 AM
That guy was a spammer. Saying he coded a weight watchers website in SilverCreator. Pretty clever deception.