The RPG Maker Resource Kit

RMRK RPG Maker Creation => VX Ace => Topic started by: yuyu! on September 06, 2015, 03:55:32 PM

Title: [Solved] Code for "and"
Post by: yuyu! on September 06, 2015, 03:55:32 PM
Hopefully this is a quick question. ;9

I know that || is "and/or", but is there a way to just say "and" in RGSS3?




I want to use script calls to combine and simplify the conditional branches for my time events, like so:

$game_variables[12] == 8 || $game_variables[11] >= 30 || $game_variables[11] <= 40

Variable 12 = Hour and Variable 11 = Minute. So, the condition is supposed to occur between 8:30 and 8:40. The only thing not working about that is the || means "and/or" and runs the events even when all three aren't met. ;9
Title: Re: Code for "and"
Post by: Irock on September 06, 2015, 04:40:07 PM
&&
Title: Re: Code for "and"
Post by: yuyu! on September 06, 2015, 05:21:41 PM
Ahhhh! That's perfect, thank you!! :gracie:

I tried "&" to no avail. Didn't think about "&&". ;o
Title: Re: [Solved] Code for "and"
Post by: Irock on September 06, 2015, 05:34:51 PM
Yeah it's doubled like == and || (though I never understood why > and < are single characters)
Title: Re: [Solved] Code for "and"
Post by: Acolyte on September 06, 2015, 05:52:10 PM
They're doubled because single equal signs are usually used to assign variables. The other singular signs most likely have different uses as well.
In C and C++, << and >> are used as bit shifts (https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts). I don't know if it's a common thing in other languages. It seems like bitwise operations are more on the extreme technical side of things.
Title: Re: [Solved] Code for "and"
Post by: yuyu! on September 06, 2015, 06:03:13 PM
Yeah it's doubled like == and || (though I never understood why > and < are single characters)

Ohhh, duh! I can't believe I missed that! :sadmoonfacefromthatthreadss:

In C and C++, << and >> are used as bit shifts (https://en.wikipedia.org/wiki/Bitwise_operation#Bit_shifts). I don't know if it's a common thing in other languages. It seems like bitwise operations are more on the extreme technical side of things.

That's right, I did notice that from my C++ class. :D I didn't know exactly what it meant until now, though.
Title: Re: [Solved] Code for "and"
Post by: pacdiggity on September 06, 2015, 11:21:53 PM
you could also write 'and' if you're feeling boring
Title: Re: [Solved] Code for "and"
Post by: yuyu! on September 06, 2015, 11:26:13 PM
you could also write 'and' if you're feeling boring

huh? That's a thing? o.o

Just curious, but...does this mean there is also a code for just plain "or"?
Title: Re: [Solved] Code for "and"
Post by: pacdiggity on September 07, 2015, 08:37:59 AM
there are some very slight differences, but yes. several english syntax words spill in to ruby syntax - 'if,' 'then,' 'wait,' 'end,' for example. conjunctions like 'and' and 'or' do exactly what you'd think. in some senses writing some lines of code can be like writing a sentence. don't expect the interpreter to understand the socio-political implications of your prose though.
Title: Re: [Solved] Code for "and"
Post by: Roph on September 07, 2015, 10:30:07 AM
nerds
Title: Re: [Solved] Code for "and"
Post by: yuyu! on September 07, 2015, 05:08:55 PM
Oh, neat! I tried "or" and it works. :-) Pretty rad!