'if' as well as 'Game.DoOnceOnly'? [SOLVED]

Started by rickious, Wed 02/10/2013 22:28:45

Previous topic - Next topic

rickious

Hi all,

I want some text to run, only once, and only on the condition your character is using a specific view (i can just run this as a bool once the view is triggered otherwise)

And if the view or bool isnt there, I will just give a message.

So, I have used if for bools, and also DoOnceOnly, but cant think how to combine the two to do this.  Or is there another way of running a message one time only?
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

Khris

It's really simple:

Code: ags
  if (player.View == 4) {
    if (Game.DoOnceOnly("view message")) Display("message");
  }


A shorter version:

Code: ags
  if (player.View == 4 && Game.DoOnceOnly("view message")) Display("message");

This will work because due to the AND operator, the right condition is only checked when player.View equals 4, and so Game.DoOnceOnly() won't return true prematurely.

rickious

#2
Cool.  Thanks once again Kris

hmm

Edited by Mod: Please don't double post within a short period of time, especially when doing so doesn't add anything constructive. Thank you.

Edited by Rickious:Apologies for this, I had posted a followup question, but fixed it with trial and error.  For future reference, how do we delete a post (although I will also be even more aware not to post unless absolutely required.)
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

monkey0506

Generally speaking, you shouldn't delete posts or their contents. Someone else might have the same follow-up question as you did, even if it seems silly in retrospect. If you've just posted, then edit the post and add your question at the bottom. Everyone will still be notified of "new posts" (via the icon next to the thread) if you've just edited the last post.

As to the original question, you really might want to check out the scripting tutorial in the manual. This question came down to not understanding the && (logical "and") operator and/or nesting conditions. These are very basic programming principles. We're happy to help you out, but some programming knowledge is required to make a game with AGS. You'll need to have a stronger grasp of these kind of tasks moving forward. ;)

Crimson Wizard

You may also click "Report to moderator" link at the post's bottom-right corner to ask mods (err... moderators) to remove it.

rickious

I did search the manual, but I was looking for 'and' not '&&', so wasnt too obvious.  I can promise you all that I only ask on here if I have been stuck on something for well over an hour, I might (like in this case) just be searching slightly wrong.

Combined, no amount of tutorials etc have a chance when compared to the combined knowledge of the AGS community.  :-D 

I found the answer to my follow up question within a few minutes so didnt want to be shot down by people who get sick of noob questions.
--COMING SOON--
'Body Pharm' beta demo.

Body Pharm - coming soon!

SMF spam blocked by CleanTalk