Utility: RPGenerator v0.7.23 - Build your own RPG in Codea

@Slashin8r - suppose you set the large tileset as a texture for the whole floor mesh.

If (to keep the math simple) you have a tileset texture 1000 x 500, and you want the tile at x=150,y=200 with width w=100, h=height 100, then your texture mapping is x,y,w,h as a fraction of total width and height, so it is 0.15, 0.2, 0.1, 0.1

@ignatz, ok I think I understand. So I just have to use fractions to get to each location. I got 8 tile sheets on the x axis and 4 on the y axis so something like (0/8, 0/4, 1/8, 1/4) up to (7/8, 3/4, 1/8, 1/4) would grab all 32 of them, correct?



Then I just store the fractions instead of the images. And then breaking it down more I would just simply divide the fraction yet again. 4 pieces along the x axis and 6 pieces along the y axis and save the 20 locations needed instead of 20 individual images. Using the top right tile sheet to test my math, the pieces would start at (28/32, 18/24, 1/32, 1/24) up to (31/32, 23/24, 1/32, 1/24).

@Slashin8r - you got it!

Try it and see - just remember 0,0 is the bottom left corner, 1,1 is top right…

@ignatz, I actually just finished updating the code to work that way. It runs much smoother now, I have yet to see frame rate drop below 58 on my device now. The code has been updated in my Dropbox as well. Now to do the same thing with the character sprites and I will also have to add a tileset variable to the generateMap() function as I am currently calling my tile sheet set globally.

Got rid of the AutoTile tab and function now that I am using just meshes. Also added project version at the top of the main tab so you all can easily keep up with the updates.

@slashin8r - The code here will automatically download your tile set images when the program runs, so you don’t need to post links to them.

http://coolcodea.wordpress.com/2013/05/23/62-3d-downloading-images-on-demand/

If you dont use something like this, and people still have to manually download the images, I suggest moving them from Documents to Dropbox because it is a pain to have to do this manually.

@ignatz, thanks for the code, I will definitely add it in right away.

I have now implemented the code @ignatz provided. The images necessary for the project to run will now be automatically downloaded and stored into your own personal Dropbox. Make sure you have a Dropbox account and have it synced with Codea before attempting to run the project. If you do not have a Dropbox account synced, then you will have to change the image names from Dropbox: to Documents: in the Images tab. You may have to run the project twice, once to download the images, then again for it to run with the images you downloaded.

The photo download seems to be a tad buggy. It keeps looping. Then crashed codea. A restart had the files.

Edit: deleted the files and tried again. Worked without the looping but it still required a restart.

Yeah I’m not sure exactly what it is doing to cause that. For some reason it is executing setup2() before the images actually finish downloading and saving. I’ll add some alerts along the path to see where it jumps to setup2(). It also seems like there is a problem with the recursive call.

@Slashin8r - there should be nothing in setup except the call to load the images

@ignatz, that’s all I got in there right now. For some reason the variable i is always nil and so it keeps looping trying to save the images over and over, then for some reason it continues to the draw function. The code looks solid and I am unable to figure out where it is going wrong.

After setup1 is ran it will go to the draw. It does not wait for the image callback to finish. You will need to check for the images in draw before you start the draw loop. It’s a little early here and I just woke up but it appears you keep calling a nill loadImages() in line 38.

@Briarfox, I added an imageStatus check in the draw function and now it does not draw early, however we still do have the image check returning nil. Even if the images are downloaded correctly, it still isn’t returning an image when we try to read the newly downloaded images, which then causes the recursive function to run an infinite loop.

Added more imageStatus checks before each loadImage() since every once in a while I ran into an issue where the image will save but use the name of the other image I’m trying to download as well. Still getting nil image even after it successfully downloads, however.

Ok, I finally got the automatic image downloading working correctly. I had to add a table that just tracked the status of each image download and use that table to skip redownloading instead of just checking if the image exists (since this always returned nil for some reason). It will still check if the image exists so it can skip all when you already have all the images.



Next update will convert the character sprites to a single mesh just like the tiles have been converted.

Just finished converting the player images to use a mesh.



Next update will cover auto-tiling of roof/wall tiles. This one may take some time.

Updated the link to the code. It is now on GitHub and thanks to @Briarfox I was able to create an auto installer for it. Direct link to the project and link to the auto installer are available in the 1st post.

@Slashin8r you dont want to gist the AutoGist variables.

use this to exclude from gist.

--/*
autoGist = AutoGist(PROJECTNAME,"Codea RPG Maker by Slashin8r",VERSION)
    --autoGist:setKey("5945833")
    autoGist:backup(true)
--*/

Something else is wonky with your gist. Did you manual create a gist then assign the key? If so this is not correct. Comment out where you called autoGist:setKey(). It is not needed. It’s a function to set a key if your key gets corrupted. AutoGist will grab its own key. Then try updating the version number. The gist description Is created by autogist and should be left as is. It needs to contain the version number for the updater to work.

Also if you add a tab called ChangeLog it will be displayed with an update to let your users know whats new.

ChangLog.lua

--[[
Version 1.5.6
-Allow the user to create games purely by thought!

--]]

I checked your revisions. There is no need to save your version number as local data. Simply use what i posted in the above post. Also there is no need to create a gist first. AutoGist will detect if a gist needs to be created, then create it and finally save the key