will
Newish
Posts: 28
|
Post by will on Jul 29, 2009 9:25:48 GMT -5
dim File dim TheNumber dim i, k
File = OpenFileRead("TEST.txt") for i = 0 to 5 TheNumber = ReadInt(File) printr TheNumber next
For this to work you will need to create a notepad doc in the Programs directory "TEST" and fill it with something like this: 56 23 25 16 83
It doesn't really matter what you put haha. As you can see, when you run the program it comes out with extremely large numbers, instead of the numbers that are contained within the text file. How do i convert these numbers into the numbers that are stored in the text file? Any help is greatly appreciated!
|
|
|
Post by xteraco on Jul 29, 2009 10:12:05 GMT -5
Hi, you can read each number into an array of ints. The trick to what you are doing is to use readline instead of readint. Readline will return a string which can easily be converted to an int using the Val() function.
dim File dim TheNumber(100) dim i, k
File = OpenFileRead("TEST.txt")
for i = 0 to 5 TheNumber(i) = Val(ReadLine(File)) printr TheNumber(i) next
Hopefully this helps.
|
|
will
Newish
Posts: 28
|
Post by will on Jul 29, 2009 10:38:28 GMT -5
Val function = life saver! Thankyou very much xteraco!
|
|
OW
Posts a bit
Posts: 100
|
Post by OW on Jul 29, 2009 12:26:08 GMT -5
I wish I could say the same.
|
|
|
Post by xteraco on Jul 29, 2009 12:49:15 GMT -5
I wish I could say the same. OW, this code (or something similar) could be used to create an external map file format for the tile engine you're working on. With an external format like this you could create a map editor for your game. Its a pretty neat idea if you ask me. Go ahead you can thank me. ;D
|
|
OW
Posts a bit
Posts: 100
|
Post by OW on Jul 29, 2009 13:05:39 GMT -5
I'm not worried about that right now, I'm worried about spawning enemies, and I'm not advanced enough to make a map editor yet. I wouldn't know where to begin since I don't know multiple languages like you. One step at a time.
|
|
|
Post by Pizzasgood on Aug 2, 2009 10:07:10 GMT -5
You don't need multiple languages for that. Map editors can be done in B4GL (and should, because then they can reuse a lot of the code you already have, and the map should look exactly the same as it does in the actual game that way). Simple ones aren't very hard either. It's like writing a very basic paint program. The user gets a pallet of tiles, where each tile corresponds to a number. When the user clicks on a tile of the map, say map(5)(7), then you do map(5)(7)=current_tile.
(Not saying you should work on one right now or anything)
|
|