Jump to content


Funk E. Gamez

Member Since 19 Nov 2005
Offline Last Active Apr 11 2013 03:38 AM

Topics I've Started

[SOLVED]Reading Text from Files

19 August 2012 - 07:04 PM

Ok this is a really weird glitch... I have a simple code writing text to a file. I can open it up in notepad and it appears exactly as it should. But then when it tries to read the code, it gives me the first letter. Here's the code:
    if file_exists(temp_directory+"/"+scrname+".script")
    {
        scriptfile = file_text_open_read(temp_directory+"/"+scrname+".script")
        scripttext += file_text_read_string(scriptfile)
        file_text_close(scriptfile)
        show_message(scripttext)
    }
The message that pops up at the end of that just says "s", and this is what the .script file says:
show_message("This script was sent.")

I tried changing the script, and it continually returned only the first letter. :/ I tried file_text_readln but that didn't even return anything. If it's at all relevant... The source that writes to the .script file is the 39dll function, filewrite() which writes a string from the buffer. This is required because I'm transferring the script online.

EDIT: As I was writing this I just had the realization... Perhaps 39dll sent a null byte, which is then being stored in the text file. Although invisible to notepad, if there is a null byte it would probably end the reading of the string. So I tried making a file manually and it loaded that just fine. I'm thinking that's probably the issue, so now I just need to figure out how to avoid writing those null bytes... lol

EDIT2: Yup, that was it. Solved on my own... lol

[SOLVED]Get Resource ID from String

09 August 2012 - 01:08 PM

I have a game with multiple characters, and to simplify things I have a character parent which has 99% of the coding for the characters. Basically the only difference in their coding is that each one is given a few variable values, including "character id". (Which affects their sprite)

So logically I figured I would use this formula to determine the proper sprite to use for the given character:
sprString = "spr_character_stand_"+string(charid)
sprite_index = sprString
The only problem with this is... Then it thinks "spr_character_stand_0" is supposed to be a variable, rather than a resource name. (And the resource name would obviously return the sprite index.)

So is there another way to accomplish this and get the proper sprites based on the character id? I know I could always do a switch and for each case change to the appropriate sprite, but I'd rather not do that every time the character has to change sprites... And it seems like there should be a more efficient way.

[SOLVED]Null Bytes

04 August 2012 - 01:15 PM

Hello, I'm currently trying to send a sprite from a server to a client. (using 39dll) I figured the best way to do this is to export the sprite, copy its data using file_bin_read_byte, then send a message with said string. When the client receives the message, they use file_bin_write_byte to recreate the sprite, then they can add it in to the resources. However, I'm having difficulties with some of the technicalities on how image data is being read and interpreted by GM.

My first issue was that there seems to be an 8 byte size limit on strings. This meant one really long string wasn't going to send properly. So I added a writeushort prior to sending the string which contains the length of the string, then it using writestring for each character. (Which in my case turned out to be 259 bytes/characters). The client then gets the short telling the string length, and proceeds to read the number of strings as the length. (Now I'm sure some of you think this is crazy slow an inefficient, but it's actually blazing fast and as far as any human can tell no slower than sending any other message.)

So now the client has constructed a string identical to that from the server, except for one issue... It turns out to be 238 bytes. I figured this is because in raw data, there is such a thing as null bytes, but when GM sends a string the null byte is deleted and you're left with nothing. I tried this as a bug testing mechanism:
for(i=0;i < length;i+=1)
{
    tempstr = string(readstring(0))
    if tempstr = "" then tempstr = " "
    sstr = sstr+tempstr
}
Sure enough, it turned out to be 259 bytes just as it was supposed to be. The problem is... a space is not the same thing as a null byte. Also, when I try using file_bin_write_byte to reconstruct the image it just makes empty spaces. (Or null bytes, I can't exactly tell). However if I use file_text_write_string it does seem to write the string properly, (I view the image in notepad to see its data) except those darn null bytes have been replaced with spaces, of course.

So I guess my questions are:
1) Is there such a thing as null bytes in image data, and is that why the client is getting blank readstring()'s?
2) Is there a way to write null bytes to a file with GM?
3) Why does file_bin_write_byte not work and is that the issue?
4) Is this even the proper way to transfer sprite data at all, or am I not understanding something about data theory?


Any help would be greatly appreciated.

Only Drawing Last View

14 July 2012 - 04:59 PM

Alright, so I'm facing a very strange glitch with views that I've never run into before... It appears that Game Maker is only drawing the last view that I have enabled. I currently have 3 views: One for a top bar (news-ticker type of thing), the main game screen, and then a bottom menu bar. All it shows is the menu bar, UNTIL I click the menu and open it, then randomly it decides to draw about 80% of the other two views. This doesn't seem to make any sense, given that I don't have any code interfering with views; just the room settings. The only thing I can figure is that it has something to do with whether or not objects in the view are visible, or views work strangely with draw events. Everything shows up just fine if I stick it all in one view, so I don't understand what's wrong with it... Here's a picture to demonstrate the issue:

Posted Image

Bluetooth DLL?

13 May 2012 - 10:23 PM

Alright, so with Game Maker Studio in beta and expected out in a few months... It would be really helpful to have a Bluetooth DLL so we could work on communication between mobile devices and PCs, as well as from mobile devices to other devices. Unfortunately, I ran a search and didn't get much of a result. Perhaps I missed something though. So I would like to know if there are any bluetooth dlls that allow sending packets through bluetooth. Any help would be appreciated.