Page 2 of 2

Re: Love Editor [I need help!]

Posted: Wed Dec 26, 2012 6:10 pm
by Roland_Yonaba
yegorf1 wrote:But I don't know Lua and Love so good to do it at one, for example I don't know how to make file saving. And I think what isn't if I call help ^^
Well, this have been discussed a lot of times around. You can try the search button.
Basically, you can use Lua IO. See Pil, this a free online book, to learn Lua. File IO is discussed here.
Also - and this is recommended with Löve, as far as I know - you can use love.filesystem (which have some limitations).

Re: Love Editor [I need help!]

Posted: Wed Dec 26, 2012 6:36 pm
by yegorf1
Roland_Yonaba wrote:
yegorf1 wrote:But I don't know Lua and Love so good to do it at one, for example I don't know how to make file saving. And I think what isn't if I call help ^^
Well, this have been discussed a lot of times around. You can try the search button.
Basically, you can use Lua IO. See Pil, this a free online book, to learn Lua. File IO is discussed here.
Also - and this is recommended with Löve, as far as I know - you can use love.filesystem (which have some limitations).
I wanted do with love.filesystem

Re: Love Editor [I need help!]

Posted: Wed Dec 26, 2012 8:20 pm
by yegorf1
Roland_Yonaba wrote: Basically, you can use Lua IO. See Pil, this a free online book, to learn Lua.
Do you know russia books? :awesome:

Re: Love Editor [I need help!]

Posted: Thu Dec 27, 2012 3:03 am
by BlackBulletIV
Try to avoid double posting. Instead, edit your last post. (Unless of course the topic's fallen off the first page, which generally takes a few days.)

Re: Love Editor [I need help!]

Posted: Thu Dec 27, 2012 1:33 pm
by Ubermann
yegorf1 wrote:
I wanted do with love.filesystem
Maybe this can help you.

It is a small part of the "save game" algorithm in a project I'm developing:

Code: Select all

local savePlayer = nil
	
savePlayer = "player.x = " .. player.x
savePlayer = savePlayer .. "\nplayer.y = " .. player.y
	
savePlayer = savePlayer .. "\nplayer.level = " .. player.level
savePlayer = savePlayer .. "\nplayer.expToLevel = " .. player.expToLevel
savePlayer = savePlayer .. "\nplayer.exp = " .. player.exp
savePlayer = savePlayer .. "\nplayer.selectedWeapon = " .. player.selectedWeapon
	
savePlayer = savePlayer .. "\nplayer.maxHealth = " .. player.maxHealth
savePlayer = savePlayer .. "\nplayer.health = " .. player.health
	
success = love.filesystem.write("player.save", savePlayer)
Basically what it does is to save game variables as a string plus the variable value. (plus = concatenation, not math operation)
Then write it to HDD using love.filesystem.

Next, when you load the saved file, LÖVE will execute everything as if it were a normal Lua module.

You can do it like this:

Code: Select all

ok, chunk = pcall(love.filesystem.load, "player.save" )

chunk()
If you read the LÖVE wiki you will see that loading the file only with love.filesystem.load WILL NOT execute it's contents.
You need to call it manually, that is because in the example I added a chunk() statement because without it, chunk will only be a variable with some values assigned (the values you saved into the file previously)

Re: Love Editor [I need help!]

Posted: Thu Dec 27, 2012 1:40 pm
by yegorf1
Ubermann wrote:
yegorf1 wrote:
I wanted do with love.filesystem
Maybe this can help you.

It is a small part of the "save game" algorithm in a project I'm developing:

Code: Select all

local savePlayer = nil
	
savePlayer = "player.x = " .. player.x
savePlayer = savePlayer .. "\nplayer.y = " .. player.y
	
savePlayer = savePlayer .. "\nplayer.level = " .. player.level
savePlayer = savePlayer .. "\nplayer.expToLevel = " .. player.expToLevel
savePlayer = savePlayer .. "\nplayer.exp = " .. player.exp
savePlayer = savePlayer .. "\nplayer.selectedWeapon = " .. player.selectedWeapon
	
savePlayer = savePlayer .. "\nplayer.maxHealth = " .. player.maxHealth
savePlayer = savePlayer .. "\nplayer.health = " .. player.health
	
success = love.filesystem.write("player.save", savePlayer)
Basically what it does is to save game variables as a string plus the variable value. (plus = concatenation, not math operation)
Then write it to HDD using love.filesystem.

Next, when you load the saved file, LÖVE will execute everything as if it were a normal Lua module.

You can do it like this:

Code: Select all

ok, chunk = pcall(love.filesystem.load, "player.save" )

chunk()
If you read the LÖVE wiki you will see that loading the file only with love.filesystem.load WILL NOT execute it's contents.
You need to call it manually, that is because in the example I added a chunk() statement because without it, chunk will only be a variable with some values assigned (the values you saved into the file previously)
Ubermann, thanks, I think it will be very helpful (or useful I don't know ^^)

Re: Love Editor [I need help!]

Posted: Thu Dec 27, 2012 1:41 pm
by yegorf1

Code: Select all

ok, chunk = pcall(love.filesystem.load, "player.save" )

chunk()
what is ok and pcall ?

Re: Love Editor [I need help!]

Posted: Thu Dec 27, 2012 2:08 pm
by yegorf1
thanks google for pcall :)

Re: Love Editor [I need help!]

Posted: Sun Dec 30, 2012 6:20 pm
by jjmafiae
yegorf1 wrote:Hi, all!

Please help me with my project!
Status: opening file, syntax finding/

I'm a C# programmer and when I found a Love framework it was awesome! But when i start finding for a good compiler I didn't find it. And now I working on Love Editor on what i started making on Love. But I don't know Lua and Love so good to do it at one, for example I don't know how to make syntax. And I think what isn't if I call help ^^

P.S. I'm sorry for my english beacose I'm russia user :)

Source (Last): http://www.mediafire.com/?b03zr1uw31gygdg

Old versions:
-- http://www.mediafire.com/?8726652aqx064i2
-- http://www.mediafire.com/?7ku0br062opaktr
-- http://www.mediafire.com/?ayjcc57cpz5wt39

P.S. If you downloaded please write at topic.

Good day!

dude are you russian that's awsome could you translate a few things for me?