Score move to game over scene

Hello first sorry for my english…
I have last question for my game. I am trying to three days moving score to game over scene.
But always is score 0. Ball in collision with a grey coin collect score. Red coin or fall down change scene to game over. Remove score scene, change game over but is alway 0. Here is my blend.
Thank you very much!

Peter

ballBlender.blend (1.61 MB)

it happens because the message to the gameoverscene score can not be sent because the scene is not active untill you reach the red coin.
you should save the score in the main scene, store it and retrive in gameoverscene.
to do that you need a seveload method, you can find a pair of them here http://blenderartists.org/forum/search.php?searchid=4448562

Thank you giobbo! But your link not work

search in game engine resources for a saveload method

I try this tutorial

but work only debug score. Not work text - dynamic text :frowning:

thank you!

…I try, but I do not understand. I create coin counter (press S save coin, press L load) but change game over scene, I don´t know make a score with automatic loaded.

ballBlender.blend (1.18 MB)

Ok, I rework my game. Press backspace, counts a score (debug) and press G save score and change scene to game over scene. Score is here, this is ok.
But change press G to collision with object etc. fall down floor, saving score not work.
I setup floor on collision with ball, add collision sensor - python save score script. But not work. Only press keyboard key saving script working hmm…

Simple, I need collision detection - save score and load

import bge

def setProp():
    cont = bge.logic.getCurrentController()
    own = cont.owner


    #Get property name
    score = own['prop']


    #store property in globalDict
    bge.logic.globalDict['prop'] = own['prop']
    
def getProp():
    cont = bge.logic.getCurrentController()
    own = cont.owner
    always = cont.sensors["always"]


    #Get property name
    score = own['prop']


    #load property TipSet from globalDict
    own['prop'] = bge.logic.globalDict['prop']
    if always.positive:
        own['prop'] = bge.logic.globalDict['prop']

To send a message to an object, it has to be in an active scene, otherwise you have to save that property somewhere so you can retrieve it when your next scene is loaded.

Your main score, the one that works should be attached to the setProp module, this will save the property value in globalDict.

Your other score, on the main menu or wherever, should be attacthed to the getProp module

thank you for answer thelaurent. But my python skill is very very poor :frowning:
I really help for me If someone editing my .blend file with this code. I can not modify this code…

I don’t send messages, I copy properties. whenever I need to save scores, inventory etc between scenes, I always copy properties. You can’t do this between scenes without python. Which is a shame.

Take a look at this blend that uses a copy properties between scenes script, that I found in resources. I don’t know who wrote the script, but it works great. http://www.pasteall.org/blend/40227

EDIT: Rename the file from .php to .blend. Nothing is going right for me this week. Sorry.

Press the spacebar to add to the score. Notice how it changes the score in both scenes. It’s copying the Text property. Instead of sending messages. Now quit blender, and re-open the blend file. Press play, and your last score will load. Thanks to Cotax for his save/load script. Move the Blend file to a different PC, and it still works. It’s a bit complicated to set up, but I know you can do it. :slight_smile:

Have the property that works running the python module setProp, have the one you want to affect running getProp. use always sensors. change prop in the script to the name of the property you want. done.

Thank you… I created simple test scene with your code. Box moving press W forward and press S backward. On hit wall added a score.
And falls to blue plane, change “scene” to “over”. But score not saved. Also I want to score reset press R.

test2.zip (165 KB)

Example.blend (527 KB)

There you are sir! you were so very close! the only thing was the always sensor was mis-named and your text property in your end scene needs to take its value from a game property like youve done in your first scene.

Although I dont know that I would hold the score value in the objects the player is hitting, the score could be a property in the player and when you hit an object it sends a message to the player to increase the score by one. you could also have a message that resets the score

either way good luck and happy blending

Ou big thanks for you friend!
My logical mind is probably too weak

but one problem :smiley:
if is score 1 and fall down box change game over scene to 1… it´s ok…
Then if score 0 and fall down box on game over scene is 1 not a 0 hmm

Because on red box the module setProp is only being activated when the property is changed. So if you change that to an always sensor to the same module you should be good to go.

two easy practices to mention:

  1. create the game over display in the main scene underneath the gamesurface for example or behind a wall and change the camera to where it is, when the game is over. the easiest way to get the job done.

2 if you use a hud and have a hud overlay scene running during the game, use it to calculate the scores there. if you hit a target in the mainscene, send a message “hit target”. let the hud scene get the message and than increase score there. i use this most of the time in my games. much easier than to send values and it doesnt matter where the counting takes place.

thank you very much! Problem is solved… many thanks to all
S-Markt yes, is very simple idea :smiley:
Your names will in credits :wink: