Beebe Class game.loadValue Not Working

Hi, I have a question about game.loadValue using Beebe class
If anyone can help me or point me the right direction will be
greatly appreciated Thank you!

I will try explain the structure of my game:

main.lua: I have a local test = game.test
game.test = 1

selectlevel.lua: I have a button which takes you to level1(level1.lua)
and a button takes you to level2(level2.lua)
I already have the functions and event listeners connected with my
buttons to take me to level1 and level2, The problem is the following
in order to go to level2, in my button2(takes you to level2) I have a
function which will only take you to level 2 if game.test == 0.
in order to make game.test = 0 the player must first complete level1.

level1.lua: When the player completes level 1, I have game.test = 0
and game.saveValue(“test.txt”, game.test) I have also tried
using .data instead of .txt to see if it made a difference but
no luck. So i`m using .txt to monitor my test.txt to see if a
0 exist when player completes level1 and it does.

So far so good when player completes level 1 then game.test = 0 and
now in my level selection I can go to level2 but If i exit the game I no
longer can go to level2 even if I saved in a file that game.test = 0

So i tried implementing in my main.lua and selectlevel.lua (neither worked)
a game.loadValue(“test.txt”) and I implemented in different ways and so far
no luck. I tried ways like local game.test = game.loadValue(“test.txt”)
or local score = game.loadValue(“test.txt”) and changing the functions
of my button to if score == 0 instead of if game.test == 0 none seem to
work so I figure my problem is i`m not loading the value?

Note:I have tried many test with Runtime to see if when for example:
score == 0 a new image appears and if I code score = 0 (it works) the
image appears but if I code score = game.loadValue(“test.txt”) guess what
no image appears :frowning:

I`m still pretty new to corona/lua and programming itself I been working
on a game for over 2months and so far is pretty much completed runs fine
on corona simulator, xcode simulator, and iphone4,ipod,ipad.
Saving/loading is the last thing my application needs and is so frustrating
after all this time working hard and learning to program I cant seem to go
any further.After days studying files / SQLite I found Beebe Class(great class)
but now I ran into this problem :frowning: Any help is GREATLY appreciated Thank You!

Note:The Sample Codes/Structure posted above is not my real game because If
I will share my game it will be too many codes so I broke it down to a sample
which if I can make the sample work I can implement the solution to my game!

I also started this Post a few days again due to this same problem and so far no
luck: http://developer.anscamobile.com/forum/2011/03/16/please-help-saveload-game-lockunlock-levels

[import]uid: 30314 topic_id: 8007 reply_id: 308007[/import]

Also if I use False or True instead of numbers I get a Runtime
error when doing a game.saveValue so I had to change to numbers
instead of False and True is this supposed to happened?

Numbers instead of false/true seem to work but just wondering
if you cant save false/true in Beebe Class

Thanks in Advance! [import]uid: 30314 topic_id: 8007 reply_id: 28494[/import]

Hi kurosaki88!

I suppose, you forgot to convert the save-string into a number.

See the example code by jonbeebe himself:
http://developer.anscamobile.com/code/beebegames-class#comment-15706 [import]uid: 42078 topic_id: 8007 reply_id: 28503[/import]

@sidasa

Thank you so much you a life saver now it seems to be working great
im having problem building the app now its crashing and before
Implementing the save/load was running fine. But I guess this is
a different topic lol

Thank you! [import]uid: 30314 topic_id: 8007 reply_id: 28525[/import]

kurosaki88

Can you help me out? I have been following your posts and I’m glad to hear you figured it out. I know the basics idea of it, but I don’t know how to physically implement it.

Beebe class doesn’t take the place of director does it?

Can you share some game code? Obviously delete any code that relates to your game so no one steals it. I’m just looking for the saving levels (level1 == 0, level2 == 0, etc) [import]uid: 32061 topic_id: 8007 reply_id: 29225[/import]

@ 4d32petersc

Hi, thanks for following my post and I hope it has helped you
but there is one thread started by someone else who wanted
to know how to show player the levels he/she has completed.
Which in reality is alike locking and unlocking or saving data.

I tried to give a simple as possible explanation and hopefully
this will help you out check out this link :slight_smile:

link: http://developer.anscamobile.com/forum/2011/01/21/show-user-level-has-been-completed [import]uid: 30314 topic_id: 8007 reply_id: 29280[/import]