Topic:   Strings Strings and more Strings   (Read 14810 times)


0 Members and 1 Guest are viewing this topic.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Strings Strings and more Strings
« on: December 05, 2011, 06:34:14 PM »
This happens every time and I'm sure this has come up before BUT how do I change a square of the map$ array?
FOR EXAMPLE:
map$(1) = "1,1,1,0,P,0,1,1,1,1"
I want to make the "P" a "0". Is it REPLACE$ or is that a different purpose?
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: Strings Strings and more Strings
« Reply #1 on: December 05, 2011, 07:34:29 PM »
Mmmm look in the Sc forum. I remember Redd making a function just for this using some NTHFields.

Circuit


  • GMG-er

  • **


  • Posts: 299

  • blast from the past
Re: Strings Strings and more Strings
« Reply #2 on: December 05, 2011, 10:49:16 PM »
I'm sorry I can't help.  I just wanted to ask a question.  Why are you using a string as an array instead of using a real array?

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: Strings Strings and more Strings
« Reply #3 on: December 05, 2011, 10:58:41 PM »
He's using both. He's making a double array and Sc doesn't support double arrays so he's forced to use a real with a fake inside.

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: Strings Strings and more Strings
« Reply #4 on: December 06, 2011, 09:08:18 AM »
SC doesn't seem to have much of the help done for the commands syntax. I was trying to do it with REPLACE but I don't know the right way to use it. There doesn't seem to be a LEFT$, RIGHT$, or MID$ either.

EDIT: OK there is a MID$ and you can use that in place of LEFT$ and RIGHT$ as well.
« Last Edit: December 06, 2011, 09:40:03 AM by AlStaffieri »

Al Staffieri


  • GMG-er

  • **

  • no avatar

  • Posts: 452

  • I love GameMaker
Re: Strings Strings and more Strings
« Reply #5 on: December 06, 2011, 09:30:36 AM »
Looks like there's a lot of the command help in SC 1.5, Someone should try transferring it over or make a text file of it and include it with SC 1.6.

Here's how to do it:

LET map$(1) = "1,1,1,0,P,0,1,1,1,1"
' make a new string using chars 1 to 8 of map$(1)
LET change$ = MID$(map$(1),1,8)
'add on a 0 and then use 10th char onward from original map$(1)
LET change$ = change$ + "0" + MID$(map$(1),10)
' now set map$(1) to the new string you made
LET map$(1) = change$

« Last Edit: December 06, 2011, 09:36:19 AM by AlStaffieri »

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: Strings Strings and more Strings
« Reply #6 on: December 06, 2011, 03:12:48 PM »
Thanks for the help! I should try to just make a method for this, and save it as a file.
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

GMG Kurt


  • GMG-er

  • **


  • Posts: 682

  • Sorry for being such a noob
Re: Strings Strings and more Strings
« Reply #7 on: December 06, 2011, 06:20:12 PM »
I hate that about SC. I always wanted to learn it, but was deterred by the lack of documentation.
Just your average Weekend Warrior.
Yes I know I have bad spelling, it's what makes me such a good programmer!

"Old art, weather magnificent or wretched, is always the raw material of new art. The artist's job, though, is to

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: Strings Strings and more Strings
« Reply #8 on: December 06, 2011, 06:38:35 PM »
All the docs are in 1.5.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: Strings Strings and more Strings
« Reply #9 on: December 06, 2011, 10:38:43 PM »
I'll post a method to replace a part of a string$ soon.
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: Strings Strings and more Strings
« Reply #10 on: December 08, 2011, 12:34:20 AM »
I DID IT. I can replace a field, i can move around on the board... Now I just need to program in goals and moving boxes! Which just means I have to make another section of code for ALL FOUR DIRECTIONS. I think I'm gonna make a method for handlemovement. But I will post the current project shortly! :D ;D

EDIT: That was easy. Thanks MF.
http://www.mediafire.com/?av7f7t0tv38e6ax
« Last Edit: December 08, 2011, 12:37:09 AM by Connors »
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: Strings Strings and more Strings
« Reply #11 on: December 08, 2011, 08:10:44 AM »
Looks pretty sweet. Possible bug, when there is a block to your right, you hit the right arrow, then you hit the up arrow you can cut across diagonally.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: Strings Strings and more Strings
« Reply #12 on: December 08, 2011, 09:10:15 AM »
That is weird... I think it's because it executes code for both arrows if you hold them down. I need to use IF ELSE for the keys.
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: Strings Strings and more Strings
« Reply #13 on: December 13, 2011, 11:11:02 PM »
Quote
That is weird... I think it's because it executes code for both arrows if you hold them down. I need to use IF ELSE for the keys.
Never mind, it just worked one way, and it's not a big problem right now since you can't really go through diagonals.
EDIT: I accidentally fixed it! You can't move twice really fast appearing to go across the diagonal anymore. XD

While we're talking about SC can conditionals in IF statements use AND or OR? I really would like this. I'm not sure how to do it. I have to make it push boxes onto floors OR goals and I want to walk across either of these. If I can't say OR it will require TWO COPIES OF THE SAME CODE. Thanks again!
« Last Edit: December 13, 2011, 11:17:36 PM by Connors »
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: Strings Strings and more Strings
« Reply #14 on: December 13, 2011, 11:29:36 PM »
I actually don't know if Sc supports this...
Make a temporary int, set it to 0.
If floor set temp int to 1
If goal set temp int to 1
If temp int is 1 then run move code

That's a little work around I suppose.