[Help]Creating a clicker game

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: [Help]Creating a clicker game

Post by sefrojones » Thu Aug 27, 2015 8:07 pm

Without knowing exactly what you've tried, it's hard to tell what is going wrong. Try this in a button:

Code: Select all

on mouseup
   put "this is an example of writing text to a file" into URL ("file:"&specialfolderpath("Desktop")&"/test.txt")
end mouseup
this should create a test.txt file on your desktop.

--Sefro

AgentItay
Posts: 60
Joined: Mon Aug 24, 2015 8:54 pm
Location: Israel

Re: [Help]Creating a clicker game

Post by AgentItay » Thu Aug 27, 2015 8:32 pm

sefrojones wrote:Without knowing exactly what you've tried, it's hard to tell what is going wrong. Try this in a button:

Code: Select all

on mouseup
   put "this is an example of writing text to a file" into URL ("file:"&specialfolderpath("Desktop")&"/test.txt")
end mouseup
this should create a test.txt file on your desktop.

--Sefro
What you gave me is working, thanks. But if I try to save a button and/or a label, it creates a blank .txt file.

sefrojones
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 447
Joined: Mon Jan 23, 2012 12:46 pm

Re: [Help]Creating a clicker game

Post by sefrojones » Thu Aug 27, 2015 9:49 pm

AgentItay wrote:But if I try to save a button and/or a label, it creates a blank .txt file.

You will not be able to "save" individual buttons and labels, but you can save information about them, or even a stack containing them. You should definitely Have a look through the first eight or so Scripting Conference stacks, as well as the one about working with files and folders. The BYU course also has a section a bit further down the page about working with external files as well.

--Sefro

AgentItay
Posts: 60
Joined: Mon Aug 24, 2015 8:54 pm
Location: Israel

Re: [Help]Creating a clicker game

Post by AgentItay » Fri Aug 28, 2015 12:16 am

I can't seem to find an option in the tutorial to make it save the button's script, so it won't stop adding points after creating a txt file.
I assume it's too hard for a beginner like me? Maybe I need to cover up even more things before learning that?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9582
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: [Help]Creating a clicker game

Post by dunbarx » Fri Aug 28, 2015 12:48 am

There are two schools of thought in saving data in a standalone. Sefro is clearly a fan of text files. I am a fan of splash stacks. You need to learn about both.

But the concpt is the same. The executable cannot save its own data. This is not a LC thing, it is an OS thing. So I make a simple stack, perhaps only with the functionality of opeing another stack. All the work is done in that other stack (or stacks) and those can be saved. The whole thing is packaged together in the standalone.

You have jumped into LC full speed. Great. But you must learn the basics, or you will never be able to leave this forum with beginner questions. Nobody minds these questions, but you should. :D

Take your time, learn and play, and ask your questions. But if it gets to the point where we are building your app, instead of simply guiding you along, we will start using these: :roll: :evil: :shock: instead of these: :D :wink:

Craig

AgentItay
Posts: 60
Joined: Mon Aug 24, 2015 8:54 pm
Location: Israel

Re: [Help]Creating a clicker game

Post by AgentItay » Fri Aug 28, 2015 9:56 am

I do understand that but I am completely lost, I tried everything you both said, I tried doing it myself, none of it worked, I tried using a tutorial to save the state of the card into a temp variable, and when the stack starts the variable will load or something like that, none would work.
I also tried saving the button script which only saves the script, nothing else, give me hints? :3

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: [Help]Creating a clicker game

Post by Simon » Fri Aug 28, 2015 11:57 am

Hi AgentItay,
Here are the 2 methods Sefro and Craig have talked about;
http://lessons.runrev.com/m/4603/l/4409 ... ng-to-file
http://lessons.runrev.com/m/4071/l/1737 ... pplication

Both of those lessons work.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

AgentItay
Posts: 60
Joined: Mon Aug 24, 2015 8:54 pm
Location: Israel

Re: [Help]Creating a clicker game

Post by AgentItay » Fri Aug 28, 2015 1:34 pm

Thanks Simon!
The second mehtod seems great, I also tried it myself.
I am having problems with the first one, so will the second method work on mobiles or only on desktop?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: [Help]Creating a clicker game

Post by Simon » Fri Aug 28, 2015 1:41 pm

Hi AgentItay,
You tell me and then we'll both know.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

AgentItay
Posts: 60
Joined: Mon Aug 24, 2015 8:54 pm
Location: Israel

Re: [Help]Creating a clicker game

Post by AgentItay » Fri Aug 28, 2015 1:54 pm

Simon wrote:Hi AgentItay,
You tell me and then we'll both know.

Simon
I am having an error trying to export it to an apk file, it says "There was an error while saving the standalone application. Could not compile application class"
Therefore, I am unable to test it on my android phone, and I also don't know how to put the .livecode file along with the Launcher.apk file.

AgentItay
Posts: 60
Joined: Mon Aug 24, 2015 8:54 pm
Location: Israel

Re: [Help]Creating a clicker game

Post by AgentItay » Fri Aug 28, 2015 9:00 pm

I got it working, but when I try to install the APK file it says "Application wasn't installed" for some reason.....
And I still don't know how to use the second method Simon gave me on android, any kind of help would be appreciated.
And Craig, no matter what I do, the script you gave me stops adding points when I exit the stack, both .livecode and standalone.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9582
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: [Help]Creating a clicker game

Post by dunbarx » Sat Aug 29, 2015 5:50 am

When you say "exit the stack" do you mean open another stack? Or go to another application, with LC still running tn the background? Or do you mean quit LC?

Neither of the first two actions should stop that handler. Write back and tell me exactly what you are doing. We will work this out...

Craig

AgentItay
Posts: 60
Joined: Mon Aug 24, 2015 8:54 pm
Location: Israel

Re: [Help]Creating a clicker game

Post by AgentItay » Sat Aug 29, 2015 9:47 am

Quitting LC and closing the stack while LC is still running and then re-open it, and also open another stack, all of the following makes this handler stop.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 9582
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: [Help]Creating a clicker game

Post by dunbarx » Sat Aug 29, 2015 1:24 pm

Well, quitting LC I understand.

But if you build that test stack from above(the one with those two buttons and a field), it should not stop. Mine does not. You did this, right?

On a new card make two buttons and one field. Name one button "StartProcess", and In its script:

Code: Select all

on mouseUp
   addDough
end mouseUp

on mouseEnter
       set the label of btn "stopHandler" to "Halt"
end mouseEnter

on addDough
  if the label of btn "stopHandler" = "halted" then exit addDough
   add 0.2 to fld 1
   send "addDough" to me in 12 ticks --0,2 seconds
end addDough
For the other button, name it "stopHandler", and in its script:

Code: Select all

on mouseUp
   if the label of me = "Halt" then set the label of me to "Halted"
   else set the label of me to "Halt"
end mouseUp
You are telling me that if you start the counter, and then click on the finder, say, or some other open application where you can see the stack, that counter stops?

Craig

AgentItay
Posts: 60
Joined: Mon Aug 24, 2015 8:54 pm
Location: Israel

Re: [Help]Creating a clicker game

Post by AgentItay » Sat Aug 29, 2015 1:35 pm

I am doing exactly what you said, I even created a new mainstack now and tried this again, but it doesn't work.
And no, it only stops whenever I close the stack or/and livecode.

Post Reply

Return to “Talking LiveCode”