damage from enemy and destroying object

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: damage from enemy and destroying object

Post by dunbarx » Tue Mar 01, 2016 2:45 am

Hi.

Simon made a point. You may not make (easily) Call of Duty 9, but you can surely make your app. I was merely trying to make you see that certain languages have certain strengths. Many new users, often young, come here and want to make games. Fine and good. Richard Gaskin just posted an excellent exposition on just this sort of thing. See the thread "Re: Livecode vs Other Cross Platform Development Tools" in the intermediate section.

But I am an LC advocate through and through. I say bring it on...

As for your stack locking up, you may have a loop that starts on openCard or someSuch, and that is what appears to be frozen. Have you tried Cmd-Period during that time?

You also can open another stack, and in some manner "edit the script of stack "yourFrozenStack". But know that if there really is something wrong, or a loop is running, then you may be blocked from that option. But if you can get to any part of that stack that is NOT frozen, then try editing scripts( or commenting large sections out). That stack has to either open or in memory for you to do that. Good Luck...

Craig

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 332
Joined: Sun Apr 15, 2012 1:17 am
Contact:

Re: damage from enemy and destroying object

Post by Newbie4 » Tue Mar 01, 2016 2:52 am

Before you open your stack, suppress all messages and errors. That will allow you to find and fix the offending line
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

ethanCodes
Posts: 46
Joined: Sun Feb 14, 2016 9:08 am

Re: damage from enemy and destroying object

Post by ethanCodes » Tue Mar 01, 2016 3:05 am

dunbarx wrote:
I was merely trying to make you see that certain languages have certain strengths. Many new users, often young, come here and want to make games.
I know what you mean. I am not one of those people. lol. Like I said, I wouldn't even know what LC is if it wasn't for this class. Not saying I don't like LiveCode. It just takes some getting used to. But I definitely would not use it to make games.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: damage from enemy and destroying object

Post by jacque » Tue Mar 01, 2016 5:13 am

ethanCodes wrote:I completely agree with you guys that this is not the program to use for making this game, however it is an assignment for a class, and the choices of games were limited. Thank you for some of the answers. I will continue to look into these. I have run into a bit of a snag. While experimenting with some bits of code, I seem to have done something that immediately freezes the program when it gets to the card with the problem code. The problem is that I must have accidently saved it after this code was activated, because now every time I open that program, it freezes. Is there any hope to somehow get back to the source code so I can delete that code? Or am I doomed to start over from scratch...
You're okay, the code is probably in an infinite loop. There is a button on the top toolbar labelled "Messages". Click that so it gets bolded. That stops your scripts from running. Then you can go to that card and fix the script that is hanging things. Remember to click Messages again when you're done so your revised scripts will run.

Edit: BTW, I've made several games with LC, just not battle/action games. Mine are more sedate.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: damage from enemy and destroying object

Post by dunbarx » Tue Mar 01, 2016 6:05 am

Ethan.

Chek out Jacque's "Blocks" in the sample stacks section. Addictive. I went to a support group to kick the habit.

Craqu

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: damage from enemy and destroying object

Post by FourthWorld » Tue Mar 01, 2016 8:10 am

ethanCodes wrote:...it is an assignment for a class, and the choices of games were limited.
I'm impressed that your instructor chose this exercise. I'm collecting info on uses of LiveCode in education, and if your instructor would be interested in helping me identify ways we can improve the LiveCode experience for educators please pass along my email address: richard AT livecode.org
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

ethanCodes
Posts: 46
Joined: Sun Feb 14, 2016 9:08 am

Re: damage from enemy and destroying object

Post by ethanCodes » Wed Mar 02, 2016 12:53 am

jacque wrote:
You're okay, the code is probably in an infinite loop. There is a button on the top toolbar labelled "Messages". Click that so it gets bolded. That stops your scripts from running.
You are a life saver! Thank you so much man! So, the code that caused this whole catastrophe was "on openCard wait timeStart seconds" where timeStart was a variable holding 180. Why would this cause the program to freeze?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: damage from enemy and destroying object

Post by dunbarx » Wed Mar 02, 2016 1:26 am

It didn't "freeze", it was just doing what you told it: wait 3 minutes.

You need more patience.

Craig

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: damage from enemy and destroying object

Post by jacque » Wed Mar 02, 2016 8:24 am

dunbarx wrote:Chek out Jacque's "Blocks" in the sample stacks section. Addictive. I went to a support group to kick the habit.
:) This gave me a warm glow and a laugh. Thank you.

I'll have to check the version in the sample section, I updated the graphics and images a while back but I don't remember if I uploaded that one. It looks better now.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

ethanCodes
Posts: 46
Joined: Sun Feb 14, 2016 9:08 am

Re: damage from enemy and destroying object

Post by ethanCodes » Thu Mar 03, 2016 4:44 am

dunbarx wrote:It didn't "freeze", it was just doing what you told it: wait 3 minutes.

You need more patience.

Craig
but why would it not let me stop the code? I put the amount of time in a variable so that I can use a button to change that variable to 0, thus skipping the wait time. But it didn't seem to work.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: damage from enemy and destroying object

Post by jacque » Thu Mar 03, 2016 9:28 pm

ethanCodes wrote:
dunbarx wrote:but why would it not let me stop the code? I put the amount of time in a variable so that I can use a button to change that variable to 0, thus skipping the wait time. But it didn't seem to work.
The "wait" command is blocking, that is, nothing else happens until the wait period finishes. You can add "with messages" to allow other events to occur, but the handler that contains the wait command will still not continue until the waiting period is over.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

ethanCodes
Posts: 46
Joined: Sun Feb 14, 2016 9:08 am

Re: damage from enemy and destroying object

Post by ethanCodes » Sat Mar 05, 2016 4:44 am

Oh I see. so I am trying to set a wait time before the enemies start advancing, but I need to be able to set that wait time to 0 and start them immediately if a button is clicked. Right now I have the wait command set at 180 seconds, and the 180 is held in a variable. the start now button has code that says on mouse up put 0 into timeStart, which I believe should change whatever is in timeStart to 0, thus ending the wait period. But it's not working. Any ideas?

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: damage from enemy and destroying object

Post by dunbarx » Sat Mar 05, 2016 5:44 am

If I get what you are saying, you want to get rid of that constant 180. Perhaps, instead, wait until an action is performed. Something like:

Code: Select all

wait until the mouse is down
or
wait until the mouse is down and the mouseLoc is within the rect of button "start"
Do you see what that last option simulates? Remember that wait is still blocking; this is a way out, that seems to act as if clicking a button kills the block.

Or, as Jacque mentioned, if you allow messages, you can do other things, but this might still hang you up

Better never to wait at all. There are better methods entirely. I would need to know more about your desired sequence to advise you

Craig

ethanCodes
Posts: 46
Joined: Sun Feb 14, 2016 9:08 am

Re: damage from enemy and destroying object

Post by ethanCodes » Sat Mar 05, 2016 6:24 am

each level of the game needs to wait 180 seconds before enemies start to come, but the player also needs to have the option of skipping the wait time. Here is the code I tried to use, but it is giving me an error:

Code: Select all

   wait for timeStart seconds or until mouse is down and mouseLoc is within rect of button "Start Now"

AxWald
Posts: 578
Joined: Thu Mar 06, 2014 2:57 pm

Re: damage from enemy and destroying object

Post by AxWald » Sat Mar 05, 2016 12:34 pm

Hi,
ethanCodes wrote:

Code: Select all

wait for timeStart seconds or until mouse is down and mouseLoc is within rect of button "Start Now"
Guess "wait for ... or until ..." will not work :) But you could have a look at this card script:

Code: Select all

global WaitEnd

on opencard
   put Empty into fld "txt_fld"
   put the seconds +180 into WaitEnd
   WaitInit
end opencard

on WaitInit
   if WaitEnd is 0 then
      put "ACTION!" into fld "txt_fld"
      exit WaitInit
   else 
      if the seconds < WaitEnd then
         put WaitEnd - the seconds into fld "txt_fld"
         send "WaitInit" to me in 1 second
      else
         put "ACTION!" into fld "txt_fld"
         exit WaitInit
      end if 
   end if
end WaitInit
Exercise left for you: What does the "Stop" button do, what happens here, and how do you use it in your stack? ;-)

Have fun!
Attachments
DEDO.zip
a little example stack ...
(789 Bytes) Downloaded 232 times
All code published by me here was created with Community Editions of LC (thus is GPLv3).
If you use it in closed source projects, or for the Apple AppStore, or with XCode
you'll violate some license terms - read your relevant EULAs & Licenses!

Post Reply