Using scenes in a conditional statement.
Aero_Swag
Member Posts: 14
Can someone explain to me how I can use my scene numbers in a conditional statement? So something will ONLY happen if it's on this screen number.
Comments
To access scene attributes, you must unlock an actor on the scene. You would then have access to the scene name, for example. There isn't a built-in scene number attribute, though. What I recommend instead is using a game attribute that you create called game.sceneNumber (integer). In each scene, have an actor that has the behavior (no rule needed) Change Attribute game.sceneNumber to game.sceneNumber+1. Then you can use that attribute as a rule condition.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I am having problems still can you explain more please?
When I have a rule it only works sometimes and usually I have to go in and out of editor for my rule to work in preview mode. Is there a way I can fix this problem so I don't encounter this sometimes ?
Can you explain what you are trying to do?
Send and Receive Data using your own Server Tutorial! | Vote for A Long Way Home on Steam Greenlight! | Ten Years Left
Creating a game and when you do the the correct thing you go to the next scene. But the correct thing changes every scene
If attribute game.sceneNumber=1 AND attribute game.numberOfChickensCaught > 5 then change scene [next scene]
If attribute game.sceneNumber=2 AND game.spaceshipsDestroyed = 16 then change scene [next scene]
etc.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Sometimes it doesn't change the scene when the condition is true. Is this a glitch because sometimes it is true but never changes(Sometimes it does and sometimes it doesn't I think it's a bug or glitch).
Post a test project showing the fault so people can take a look and fix it for you.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
Can you give an example of this? Can you provide the exact rule you're using and a description of how it is intended to work?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
But people might steal my future app
...then post a minimal version of it. In other words, make a copy of the project file and strip it down so it's just the issue you're having trouble with. You can remove images and other identifying details. If you don't want to do all of that, then upload screenshots of your rules to a file-hosting service such as http://imgur.com and then post links to them here.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
1st Rule
[When all of the following are happening]
if game.scenenumber = 1
touch is pressed
do{
change slide
}
2nd Rule
[When all of the following are happening]
if game.scenenumber = 2
touch is pressed
do{
display: Wrong
}
I have this for like 15-20 different things but they all do something depending on the scenenumber. The problem is that it won't work all the time and it only works sometimes.
I have been trying to figure out whats wrong almost all day.
I am going to merge the two threads since they are describing the same issue.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
The tricky part here is that we can't see all of your code and therefore can't really determine the problem. You'll need to use some standard debugging tools in GameSalad such as Log Debugging Statements and Display Text to watch the value of certain attributes to see if they are in fact what you expect them to be. Touch is Pressed is a pretty solid/simple condition so if that's the ONLY condition you have besides the game.scenenumber attribute I'd be hard-pressed to tell you why that isn't working. If you actually have other conditions you haven't mentioned, well I can't guess what those might be.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
I also had to unlock an actor like you told me to so the scenes can go +1 each slide. There are only 10 levels in the game so far and each one has similar code to the one I posted(Exact that's really most of the code in the game). But sometimes it won't work when I press a button. It doesn't display "Wrong" and it doesn't change some scenes sometimes.
I think I may have found the problem. How do I fix this so this runs every scene? I unlocked the same actor on every scene but I this might be the problem...
[Change Attribute]{
set game.SceneNumber to game.SceneNumber + 1
}
This is the only other thing I have in my game, rather than me just displaying text. So if there had to be a problem in it, would it be this?
Actually when I skip scenes trying to hurry and get to another scene it messes my other scenes up.. So do you know what the cause of this is?
Nope, I don't know. You haven't really provided enough information (in the way of screenshots or a project file). That and what I suggested was not to unlock an actor on the scene. That was just an example of how you can access scene attributes. I suggested using a game attribute.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
You are asking people to spend time guessing fixes for your problem when they are busy working on their own projects. People are willing to help you but if you are not prepared to upload a test project or screenshots of your rules you are not going to get much help.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
"Messes my other scenes up" = could mean absolutely anything.
"similar code" = could mean absolutely anything.
"most of the code" = could mean absolutely anything.
"I have this for like 15-20 different things but they all do something depending . . . " = could mean absolutely anything.
. . .etc etc
As others in this thread have said, unless you are prepaid to be explicit then it's going to be very difficult for people to help, the best you can hope for is a few guesses, if you wait around for a few days (perhaps longer) you might get lucky and someone could guess what the issue is.
Ok, thanks I miss-read the solution I figured out what was wrong. You were really helpful, sorry I didn't provide enough information. In future forum post I will highly consider uploading a sample project or including images.
I guess I was just stuck on the fact that someone might re-create it and claim it as their own.