The Daily Click ::. Forums ::. Klik Coding Help ::. Computer mice and string cheese
 

Post Reply  Post Oekaki 
 

Posted By Message

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
21st March, 2009 at 16:46:53 -

I'm still making my level editor, and I want it to save to an array. I'm using the regular Array object (because I want to) and want to save three values to the same cell. To do this, I'm going to combine them into one string and save that. But, I have two questions about that:

1) Because I have three values with maximums of 99, 32, and 4, and minimums of 0, I need to convert them into strings of two characters each. Is there an easier way to do this than to create different events for each conversion? Please remember to show your work and answer in complete sentences.

2) Ignoring Z layers, can you save both values and strings to any cell? Please answer in complete sentences.

BONUS: Can you detect the number of buttons on a mouse? Please remember to show your work and answer in complete sentences.

This quiz has a maximum of 10 points. The bonus is worth 2 points. Partial credit will be awarded for questions.

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
21st March, 2009 at 23:12:28 -

Firstly, you may find it interesting to look at the TileWidget I made a while back.
It's a simple tile based level editor/loader, but it doesn't actually use the array object - instead it simulates a complete 3-dimensional array in a single text string. It actually saves the level as ascii text, using an edit box object.
Anyway, it uses all the tricks you need, and I think it's vaguely commented.

http://cid-b1e7ee094271bbda.skydrive.live.com/self.aspx/Public/TileWidget.zip

Having said that, is it not going to be easier for you to just use more Z layers?


1.)
Not sure what you mean exactly. You could use the StringParser extension, or could do it this way...

EXAMPLE
Create a String Containing 3 Values:
Right$( "0"+ Value_A, 2 ) + Right$( "0"+ Value_B, 2 ) + Right$( "0"+ Value_C, 2 )

Retrieve Values from String:
Value_A = Left$( String, 2 )
Value_B = Mid$( String, 2, 2 )
Value_C = Right$( String, 2 )


2.)
Obviously a string can hold numbers and text, so I presume you are having a problem with storing several sub-strings of unknown length, in a single string (ie. knowing where one string ends and the next begins)?

The easiest way is probably to use the StringParser extension. Separate each substring with a delimiter.

EXAMPLE
Create a String Containing 3 Values/Strings:
String_A + "|" + Str$( Value_A ) + "|" + String_B

Retrieve Values from String:
String_A = listGetAt$( "String Parser", 0 )
Value_A = Val( listGetAt$( "String Parser", 1 ))
String_B = listGetAt$( "String Parser", 2 )

Another way would be to store the length/starting-point of each substring in the first few characters, and then look up the corresponding portion of text - I won't explain in depth, as I think the substring method is easier anyway.


3.)
My gut feeling is "no", but I'm not sure.

Edited by Sketchy

 
n/a

Liquixcat

Administrator
Lazy Coder

Registered
  08/12/2002
Points
  201

VIP MemberLikes TDCKitty
22nd March, 2009 at 05:14:38 -

Sketchy hit the nail on the head. Exactly what I thought.
1)strings can hold values, so differentiating them is kinda useless.
2)parse strings with deliminator
3)no

 
thinking is like pong, it's easy, but you miss sometimes.

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
22nd March, 2009 at 12:29:35 -

First example should read:

Create a String Containing 3 Values:
Right$( "0"+ Str$( Value_A ), 2 ) + Right$( "0"+ Str$( Value_B ), 2 ) + Right$( "0"+ Str$( Value_C ), 2 )

You probably could have figured that out anyway...

 
n/a

Jon Lambert

Administrator
Vaporware Master

Registered
  19/12/2004
Points
  8235

VIP MemberWii OwnerTDC Chat Super UserI am an April FoolSSBB 3265-4741-0937ACCF 3051-1173-8012360 Owner
28th March, 2009 at 18:58:58 -

Sketchy got 10/10 points, but he didn't get the bonus question.

I now know how to use the String Parser 2 object! Yay! I got that to work.

Um... is there any way to detect when a new array is opened?

 
Sandwich Time!Whoo!

JoyCheck & KeyCheck Widgets
For easy implementation of customizable joystick and keyboard controls.
http://www.create-games.com/download.asp?id=8364
   

Post Reply



 



Advertisement

Worth A Click