you need to better explain wth it is youre trying to do, because so far youve said ok i have mapx and mapy and you have to guess what exactly those are being used for and now help me with table.insert and also im using some for loops
Printable View
you need to better explain wth it is youre trying to do, because so far youve said ok i have mapx and mapy and you have to guess what exactly those are being used for and now help me with table.insert and also im using some for loops
Umm...
Code:for i = 1, mapY do
for j = 1, mapX do
file:write(map[i][j])
end
end
Thanks nielkie :tup:
-=Double Post Merge =-
Check the dates. I might have 'millions' of threads but it's not a crime to ask for a couple of questions/suggestions. You do know this is the Lua programming Help thread. You don't have to help anyone u know. Anyway i tried to test the output and the gd news is that it writes 0 to the .txt file. But it is no array there is no map = {
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
}
it is just a huge row of 0
Well obviously... you'll have to read the map back in...
Though this is just a guide. You'll also have to store and read back the dimensions of the map. Of course, you'll have to create a more advanced way of storing each number, or what ever data type you choose to store in the array, so that each one is the same length in the file. I suggest 8-bit integers.Code:for i = 1, mapY do
for j = 1, mapX do
map[i][j] = file:read(1)
end
end
Could i just use this?
i dont know can you use a function? you tell me!
ROFL
Dan, experiment dude find things out for yourself, then if your still stuck then ask questions but thats just my opinion.
Anyway to the point, a while ago i created a little Lua file from which you could create a table of values and save that said table to a .lua file and then you could load that table from that said file.
You'll get what i mean better when you actually see it, i'm not guaranteeing that is the most brilliant thing ever but it would help you get a leg up on what you are trying to do and hey every little helps.
:D
http://www.megaupload.com/?d=2OQN2WD5
P.S i created this about 1 year ago . . . , Oh if you ever need a tile map i have one you could use, just give me a PM if you ever need it or help for that matter.
Ok, i should of been a bit more exact. I meant would it do what i want? Save a 2d array to a file, that's what i meant.
@Luke, i'd like to take a look at your example, but megaupload doesn't work for me :( . Though thanks, if say you could host on a site like sendspace, it would be grateful :tup:
Though lots of MapEditors have used that table.save() function, though i saw the output in a file and it wasn't the output i was hoping for, so that got my curious on the output hense why i asked the question,
Of course i can Dan, here's the link . . .
http://www.sendspace.com/file/kh1bwr
hope this helps you with loading tables from a file.
Thanks Luke :tup:
look at the code
make up a number for mapX and mapY, lets make each of them = 3
now run through the forloops in your head
and see what it makes
alternatively you could get something like TTLDE and test simple stuff on the psp on your own. or quit complaining that you're on your psp, because that really isn't any of our problems and if you can't test things out you shouldn't be asking for help.
I've done it now. At that moment in time, i was on my psp.
thx anyways, ya was playing around with some of the code and it worked. now just have a diff question.
|
|
|
\/
does anyone know how to extract a number from a string?
im no expert, but if you typed the code like you did above then your problem is that you have your function inside a table. the format should be:
so you would make it:Code:function functionName()
if thats what you want your function named. hope tht helpsCode:function collision(obj1,obj2)
Lol you fixed it just as i posted sucks :p
edit: oops thought this was c/c++ help thread, none of my answers would help
use string.find and string.sub
read this and don't post until you have read it and learned how the functions worked and tried to figure it out
also seen as you are extracting a number from a string you may want to take a look at the tonumber() function, as it would be held as a string because that is what you are extracting it from.
if he uses the string as if it were a number, lua will generally autoconvert it - generally tostring is the only casting function ever needed in lua.
didnt know that, do now thanks for lettin me know i have never come across that situation, but yeah i was just using logic but if its not needed then what the hey.
nvm found one
i have a couple questions..
i have this code setup inside of the while loop to exit the game when i want by simply changing the variable Quit to true. It doesnt seem to work. It just freezes the psp.
if Quit == true then
os.exit()
end
also, when i am writing a game and a map editor, and it seems when i go back and forth between the 2 i sometimes get errors like not enough memory or something along those lines. My question is.. Is there a way to clear all the memory from the last .lua you were running so you can start fresh with the new file. Im really new to programming in general and im not sure how im supposed to do everything. learning by trial and error. so i appreciate the help.
thnx in advance.
1. os.exit doesn't and never really has worked
2. just manage your memory carefully, use tables and local vars, etc - you really shouldn't ever be running out of memory unless there's something drastic that is being overlooked
I need some tuts for PgeLua if anyone can post some links I would be greatful. ^^
read my signature
umm...alot,
swizzle an image allows for the image to be drawn faster, however it does make it harder to modify the image data.
where's loading an image is simple that, loading an image into ram.
OK that is good for when I don't need to change an image, but how do I use the image.
Code:mypicture = pge.texture.load("test.png") --This returns a pointer to the image data.
swpicture = pge.texture.swizzle("test.png") --This just returns true or false (maybe 0 or 1).
When you load an image, it automatically swizzles it...
You usually don't need to unless you un-swizzled it, to change the alpha, color, or some pixels.
To use the image, depends on how you want to use it.Zitat:
object = pge.texture.load(filename , [memorylocation], [swizzle])
Parameters:
filename - The name of the PNG image to load.
memorylocation - Optional argument. Either PGE_RAM to load to RAM or PGE_VRAM to load to VRAM. Defaults to PGE_RAM if omitted.
swizzle - Optional argument. A boolean representing whether to swizzle the texture or not. Defaults to true if omitted.
To print it onto the screen :
pge.texture.draweasy(text ure, x, y, [rotation], [alpha])
or
pge.texture.draw(texture, x, y, [width], [height], [texstartx], [texstarty], [texendx], [texendy], [rotation], [alpha])
http://lmgtfy.com/?q=pge+lua+documentation
is there a way to encrypt lua or whatever it is called to hide your source code?
i want to
PGE how much better then regular lua player for psp? i think they are on .20.
would it be worth me moving from lua.20 to using pge?
ill release something for you guys to play as soon as i can find a way to hide the code. I will probably go open source later, but for now its our baby(working with another) and id like to see it through first.
so far we have some basic physics done like Mario(im using those gfx for now)
Sidescroller.
Mario physics include.
run/jump/crouch/climb
theres some makeshift monster code in with a lil ai.
i also have a map editor made with some basic features.
add/delete tile
change tile attributes (visible/collision/kill/rope/warp)
you can save to a user specified name.
anyway..... all of this done using lua player 0.20. is PGE worth moving ny project? Ive been using lplayer and have been running into issues with the psp slowing down. Im sure its my sloppy code but to an extent. Is there any significant speed boost that i can get from pge?
anywho thnx in advance, ill try and release some beta version soon.
@TurtlesPwn
Hmmm what can I say.....
@SectionEight
Ya it should give you a great boost, PGELUA is made from scrap so everything is made for speed, everything is alot faster.
Here is the Benchmark.
I think it is very well worth it, and as far as I know you can't encrypt lua code.......although if you find anything out plz PM me.
Protecting or Encrypting Lua/PGE code : http://luaplayer.org/forums/index.php?topic=471.0