Page 3 of 5

Re: [Help]Creating a clicker game

Posted: Thu Aug 27, 2015 8:07 pm
by sefrojones
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

Re: [Help]Creating a clicker game

Posted: Thu Aug 27, 2015 8:32 pm
by AgentItay
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.

Re: [Help]Creating a clicker game

Posted: Thu Aug 27, 2015 9:49 pm
by sefrojones
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

Re: [Help]Creating a clicker game

Posted: Fri Aug 28, 2015 12:16 am
by AgentItay
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?

Re: [Help]Creating a clicker game

Posted: Fri Aug 28, 2015 12:48 am
by dunbarx
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

Re: [Help]Creating a clicker game

Posted: Fri Aug 28, 2015 9:56 am
by AgentItay
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

Re: [Help]Creating a clicker game

Posted: Fri Aug 28, 2015 11:57 am
by Simon
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

Re: [Help]Creating a clicker game

Posted: Fri Aug 28, 2015 1:34 pm
by AgentItay
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?

Re: [Help]Creating a clicker game

Posted: Fri Aug 28, 2015 1:41 pm
by Simon
Hi AgentItay,
You tell me and then we'll both know.

Simon

Re: [Help]Creating a clicker game

Posted: Fri Aug 28, 2015 1:54 pm
by AgentItay
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.

Re: [Help]Creating a clicker game

Posted: Fri Aug 28, 2015 9:00 pm
by AgentItay
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.

Re: [Help]Creating a clicker game

Posted: Sat Aug 29, 2015 5:50 am
by dunbarx
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

Re: [Help]Creating a clicker game

Posted: Sat Aug 29, 2015 9:47 am
by AgentItay
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.

Re: [Help]Creating a clicker game

Posted: Sat Aug 29, 2015 1:24 pm
by dunbarx
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

Re: [Help]Creating a clicker game

Posted: Sat Aug 29, 2015 1:35 pm
by AgentItay
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.