Grid Sage Forums

REXPaint => Everything REXPaint => Topic started by: 0x41414141 on April 11, 2018, 09:43:27 PM

Title: How to use rex_spite.js?
Post by: 0x41414141 on April 11, 2018, 09:43:27 PM
I'm a beginner with node.js, but I god I fucking hate it when developers include no example or comments in their code.

I'm trying to get this script to work, but it keeps throwing the error
"TypeError: Invalid non-string/buffer chunk"

Here is my code. test.xp is the xp file I want to display.
RexSprite(fs.createReadStream('test.xp'))

http://www.gridsagegames.com/blogs/files/rex_sprite.js
Title: Re: How to use rex_spite.js?
Post by: 0x41414141 on April 11, 2018, 09:51:08 PM
I tried

fs.readFile('./test.xp', function read(err,data) {RexSprite(data)})

Now I get no errors, but also no output.
Title: Re: How to use rex_spite.js?
Post by: Kyzrati on April 11, 2018, 10:45:54 PM
Sorry I don't know anything about js myself, but you could try getting in touch with the original dev (Twitter (https://www.twitter.com/johnvillarz), GitHub (https://www.github.com/chiguireitor)). Everyone who writes those third-party libs for REXPaint uses them in their own projects, and most have samples of their work on GitHub, but chiguireitor in particular essentially disappeared from our r/roguelikedev community a couple years ago and then for some reason the page for rex_sprite.js disappeared as well so I just started serving it from my site now.

...oh actually I see now he's still got his roguelike stuff online, in which he makes extensive use of REXPaint so you can try checking there (https://github.com/chiguireitor/MultiRL) for use cases!
Title: Re: How to use rex_spite.js?
Post by: 0x41414141 on April 12, 2018, 01:45:13 PM
Ah, thanks! I see the file is slightly different, but it'll do.
Title: Re: How to use rex_spite.js?
Post by: Kyzrati on April 12, 2018, 05:35:27 PM
Oh did he change it? Maybe that's why he removed the other one (but he didn't mention it to me :P). If you confirm that the original one doesn't work but find a separate one that does, or changes that are necessary and end up getting this working for you, let me know and I'll update the resources page.

Note the one I've linked was originally a gist page, and I believe it was intended to be a single package for easy general use because he needed a somewhat modified version for his own use. In any case, I imagine you can learn more from seeing his use cases!