Author Topic: I want a control color to kill me unless I have a certain score  (Read 5080 times)

0 Members and 1 Guest are viewing this topic.

Offline jtyler125

Hello Coders,

Why is this code crashing the game???  It is driving me nuts.


(properties)
 (method (doit)
 (var dyingScript)
 (super:doit())

(if(== (send gEgo:onControl()) ctlGREEN)
(if(== gScore 3)
(send gRoom:newRoom(2))
)(else
(send dyingScript:caller(10)register("You did not do what they said so you will not see your wife ever again."))
(send gGame:setScript(dyingScript))
))

Take it easy on me I have been at it for a few hours now...

Thanks,
JT


Life is getting better all the time.
Groundhog Day Competition New Year's Competition

Offline troflip

Re: I want a control color to kill me unless I have a certain score
« Reply #1 on: March 07, 2007, 09:59:41 PM »
Because you're missing the part where you initialize the dyingScript variable.  So you're calling send on something that isn't an object at all --> crash!

(dyingScript is just a variable, you could name it anything you want - it has nothing to do with dying until you actually assign the real dying script to it)

Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline jtyler125

Re: I want a control color to kill me unless I have a certain score
« Reply #2 on: March 07, 2007, 10:52:32 PM »
Just for fun how should I change that script...by the way another hour later I came up with a new way to do what I wanted to do...of course after your statement...but I still don't know what you are talking about either...

I am 60% done with my entry just need to put finishing touches on it...will hopefully have it in by Saturday Night....can you guys wait that long?

Still not sure if better than fish tank...but it will be my best attempt...

Thanks,
JT
Life is getting better all the time.
Groundhog Day Competition New Year's Competition

Offline troflip

Re: I want a control color to kill me unless I have a certain score
« Reply #3 on: March 07, 2007, 11:27:41 PM »
You should take some time to read the tutorial on the death script here

Some excerpts from it:

Code: [Select]
(method (handleEvent pEvent)
  (var dyingScript)
  (super:handleEvent(pEvent))


Code: [Select]
(if(Said('die'))
  = dyingScript ScriptID(DYING_SCRIPT)  // This is the line of code you're missing
  (send dyingScript:
    caller(3)
    register("You're dead dude! Thank you for playing \"Tutorial Quest\"!")
  )
  (send gGame:setScript(dyingScript))
)

Basically, the ScriptID thing, as I understand it, will load the DYING_SCRIPT script (Dying.sc).  Then it will return a pointer to the first instance in that script, which if you go look in Dying.sc, happens to be
Code: [Select]
(instance public DyingScript of Script

The term "script" is a little overused here.  I'm using it to refer to both the code file Dying.sc, and also the particular instance object returned by ScriptID, which happens to be DyingScript, which is of type "Script"!  (it could be anything though... it's whatever the first instance object is in a code file)

Now, you know that rooms have Scripts associated with them, but you can also associated a special Script with the "whole game", and that is what the last line there does...

Hope that helped explain what's going on a bit.

I eagerly await your game!
Check out my website: http://icefallgames.com
Groundhog Day Competition

Offline Cloudee1

Re: I want a control color to kill me unless I have a certain score
« Reply #4 on: March 08, 2007, 10:25:47 AM »
Ok JT, you've got to quit asking new questions at the end of your other threads and then in a new thread. A brand new thread for a question about a different piece code is fine, and suggested.

I have been trying to split em up whenever I see you ask a completely different question at the end of a thread than you started with, you'll get much more help with a thread and other people will find help from your posts as well. If on reply 4 a question has been answered, people won't be in any big rush to go back in to page 3 to see why people are still talking about it. By adding completely different code questions to those posts you are limiting the number of people who would even look at it.

Did I leave that line out of the using death how to, I'll have to go check.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline jtyler125

Re: I want a control color to kill me unless I have a certain score
« Reply #5 on: March 08, 2007, 06:30:37 PM »
Sorry, I hope I don't get demoted from programmer to jr programmer.

JT
Life is getting better all the time.
Groundhog Day Competition New Year's Competition

Offline Eigen

Re: I want a control color to kill me unless I have a certain score
« Reply #6 on: March 09, 2007, 04:01:25 AM »
Don't worry, forum ranks are tied to the post count. But yeah, the death handling is all in the manual, so it might be a good idea to first check there. I know manual doesn't cover everything, but it might lead you in the right direction.
Artificial Intelligence Competition


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.031 seconds with 22 queries.