OK-New Question-How to change TV Radio stations/channels

Sonny
24 Jul 2007, 21:57
Hi all.

Sorry for the question but:

I am still trying to learn how to do things. I am now trying to figure out how to change TV Channels (maybe using a remote control) on the TV. (Or say changing Radios Stations instead).

I am starting to get the hang of using Verbs, Commands, Flags and sometimes properties and such. I have been playing around with this and can not figure out the right combinations to make this work as yet.

An example:
Player takes remote (if in room or inv and tv is visable to player)

(Player Action): Player types "Change Channel"
(Game Response): (using the remote) You change the channel. This is an old rerun of Gilligans Island.

(Player Action): Player types "Change Channel"
(Game Response): (using the remote) You change the channel. An old western is on the screen.

(Player Action): Player types "Change Channel"
(GameResponse): (using the remote) You change the channel. An old western is on the screen.

(Player Action): Player types "Change Channel"
(Game Response): (using the remote) You change the channel. the weather ~ channel is now on. Forecast is 86 degrees and clear skies.

(Player Action): Player types "Change Channel"
(Game Response): (using the remote) You change the channel to the Local News Channel. It says "man escapes from patrol car." When caught he says "he is really Houdini, reincarnated!" ... News at 11.

anyway, something like that.

======================

I am using QDK at the moment so cut and pasting the code is doable, but I would need to now where to paste it in the existing code (like A goes above rooms, B goes at bottom of code etc) As I am not yet that familiar with that part yet.

The main reason for me wanting to do this is to learn how to control an object and make it do things like this. Then I could start to play around with other things as well.

I think if it wasn't for these forums and the answers, posts here (especially Tron, Thanks) I would not be able to eventually do a game.

Sonny

Elexxorine
25 Jul 2007, 14:39
Welcome. Firstly, make a numeric variable called 'channel'. Now in the verb for changing the channel, make it add 1 to the variable, check to see if that channel is above he maximum channel on the tv (say it has 6 channels, if the channel is '7' set it to '1'). Next have select case for the channel, or a series of 'if's, which ever you prefer. Where it sets a string variable called 'tv show desc' to whatever the show is about (eg: "An old western is on the screen. "), depending on the channel (and time if you want to do that too). Now print a message saying "You change the channel. (insert tv show desc string here)", to insert the variable there's a button to push which gives you a list of variables you have, just click on it and it'll make it so it buts a value of the variable in too. And you're done. If you so which you could also set the look description of the tv to print the show description too (make sure you have it set to something before any channel is changed or it'll print an error because it's not set).

Hope this helps. If you have any more problems or are confused at all, just ask.

paul_one
25 Jul 2007, 15:52
Sounds close to how I'd do it - I approve of your methods Elle :P .

Sonny
25 Jul 2007, 21:20
Thanks Elexxorine.

As you probably guessed, I am having trouble, sorry. Below in the "Numbered sctions" are what you wrote, my questions/confusions are underneath them.

1) Firstly, make a numeric variable called 'channel'.
(?? Ok, I think I do this by choosing Game/status Variables. ??)
(?? Do I make it 0, 00, 1, or leave blank .. i left it blank)

2) Now in the verb for changing the channel,
(?? do I write something like "Change Channel" for the verb entry, what would you use ??)

3) make it add 1 to the variable,
(?? sorry, totally lost here... how do I do that ??)
(ie: edit script/variables/set a numeric variable/...then under name channel/+1 ...is this right ??

4) check to see if that channel is above he maximum channel on the tv
(i did -- look at top of editor to see it says change the numeric variable of channel to +1 ??)

5) (say it has 6 channels, if the channel is '7' set it to '1').
(?? sorry, again, really lost me here ... I haven't made any channels yet so how do I know if there is 3 channels, or 7 channels, or 6 channels or ?? ... do I need to make say 7 channels or are they made automatically ... really lost on this one)

6) Next have select case for the channel,
(?? Select Case ... ok found it ??)

7) or a series of 'if's, which ever you prefer.
(prefer the Case version)

8) Where it sets a string variable called 'tv show desc' to whatever the show is about (eg: "An old western is on the screen. "), depending on the channel (and time if you want to do that too).
(?? 'tv show desc=An old western is on the screen ??)

9) Now print a message saying "You change the channel.
(ok, that will probably be understood with the above understood. do I click Add more and "Print" here)

10) (insert tv show desc string here)", to insert the variable there's a button to push which gives you a list of variables you have, just click on it and it'll make it so it buts a value of the variable in too.
(?? maybe more clear when above is understood, where /how do I add this and to where ??)

11) And you're done.
(lol, easy for you to say ??)

12) If you so which you could also set the look description of the tv to print the show description too (make sure you have it set to something before any channel is changed or it'll print an error because it's not set).
(?? I think I understand this part ??)

----------------------------------------------------------------------------------
Note: Sorry, I know this is all clear to all of you, but not me.

Too many similar use of words in the program, such as Variable, Object, String etc. (so when you say make variable or make a string or choose object and I have 6 ways of doing that, I don't know which to choose if not directed to its location) ...
A good example: under verbs/editscript/conditional/print: You see an old western/ add more/ ... etc. on the more advanced stuff.

So please don't take for granted I know where to make that 'whatever' or "do something". I'm not complaining mind you, I just very stupid at this right now, but getting better :(.

and yes, I have gone thru the manual and Quest help parts, and still am :)

Sonny

paul_one
26 Jul 2007, 14:13
Right, get the theory behind this; (I'm having to get a VERY early night as I'm going to Amsterdam Friday at 4am.. So you will have to wait until Monday for any further help).

You create an array (a list) of 'channel' variables (channel[1], channel[2], channel[3]).. These are the descriptions for each of the channels (You see a western, you see the news, etc).

You have a numeric variable which needs to rotate along the list.. 1 to, whatever number you decide. - This is what is used to point to one of the entries in the array (remember, it's a list).

Now, when you change the channel you increment (add one, whatever) to the number variable above..... If you keep doing that, you'll go over the number of channels you have.

So after you've incremented it, you need to check (a conditional statement... 'if') whether the number above, has gone over the number of channels.
If it has, then set the number to 1 again - so you continually rotate.
If not, then that's fine.

The following expects an array of channels in the start script;
This is not real code - but might be nicer to see/read
the names are correct though: < name | value >

< channel[1] | channel 1! >
< channel[2] | the weather >
< channel[3] | woop >

So in the "change channel" verb (how you do that is really up to you), you need to:

add one to the number variable,
check to see if it's over the limit
+ and if so then change it back to 1
print the message "you change the channel to %number%. You see #channel[number]#"

Whenever you look at the TV you need to print something like:
"you see #channel[number]#"

Hope this helps with the theory - sorry I can't put up a demo.

Sonny
27 Jul 2007, 01:31
Ok, I have played with it ... But again I think ya'all are assuming I know where to do all this stuff.

1) You create an array (a list) of 'channel' variables (channel[1], channel[2], channel[3]).. These are the descriptions for each of the channels (You see a western, you see the news, etc).
>> ?? What part of the program do I do this in ??

2) You have a numeric variable which needs to rotate along the list.. 1 to, whatever number you decide. - This is what is used to point to one of the entries in the array (remember, it's a list).
>> ?? What part of the program do I do this in:

3) Now, when you change the channel you increment (add one, whatever) to the number variable above..... If you keep doing that, you'll go over the number of channels you have.
>> ?? What part of the program do I do this in:

4) So after you've incremented it, you need to check (a conditional statement... 'if') whether the number above, has gone over the number of channels.
If it has, then set the number to 1 again - so you continually rotate.
If not, then that's fine.
>> ?? Don't understand this part at all, why would it go over and why would I have to set it back to 1 again, wouldn't that just show the same channel over and over again ... and "if not thats fine" would i bother with it anyway ... confused:


5) The following expects an array of channels in the start script;
This is not real code - but might be nicer to see/read
the names are correct though: < name | value >
< channel[1] | channel 1! >
< channel[2] | the weather >
< channel[3] | woop >
>> ?? I can make the Case show below by typing it in, but I dont thein its right on my end.


So in the "change channel" verb (how you do that is really up to you), you need to:
>> ?? Sorry, Which Verb?, ... under the "TV Edit" or the "Custom edit" above the the Commnads on the left panel. Or Do I make this a command to execute the verb.

add one to the number variable,
check to see if it's over the limit
+ and if so then change it back to 1
print the message "you change the channel to %number%. You see #channel[number]#"

Whenever you look at the TV you need to print something like:
"you see #channel[number]#"

>> ?? that will probably be apparent when I get the above working correctly.

Also:
sometimes certain parts asks me for a name, do I use: Channel, Change Channel, #object#, #Channel# ... do i use the same name each time ...confused.

----------------------------------------------------------------------------------
----------------------------------------------------------------------------------
Side Note:
I checked the Help contents on Arrays, it is helpful in its explanation except it does not show you how to make one (ie: open advanced/conditional/select user has object ... so it gives no clue on how to/or where to use/start, it only shows how it works and obviously the code example it supplies has to go in one of 75 places, but which one).

I think I could understand you all more if you also told me where to at least start/go to write the coding you suggest.
...... an example of what i'm asking is #2 above:

[[[[[[[[Under Verb/edit script/Conditional/If]]]]]]]
1) You create an array (a list) of 'channel' variables (channel[1], channel[2], channel[3]).. These are the descriptions for each of the channels (You see a western, you see the news, etc).

in the example above, that at least tells me to try the verbs/conditional "places" rather than all 75 (x's 5 or 6 code tries) options ...lol!

I know the above isn't correct, just an idea of, where to go, to do, as you say ???

Thanks folks !!!

Elexxorine
27 Jul 2007, 11:09
Sonny, don't worry I'm writing up a list of instructions as I do them myself in QDK to make sure they work. I'm 2/3 done at the moment too. I've also done some screenshots to show you what things should look like if you do them correctly. By doing it as I go along, I've actually written where the buttons are so you can find them. I'll also send you the game I made so you can look at it too.

Also, to answer some confusions.

4) The 'rotating' as Tron calls it, is when you've only got say 6 channels on your tv, when you press 'channel up' on channel 6 it'll go back to channel 1 (or 0 if you want). On newer tv's you get 99 channels, but it still loops round to 0 after 99.

5) Arrays aren't needed here and will make thing more complicated. Once you get the basic tv working, arrays could be used for making a show timetable so what's on the tv will change depending on what time it is, and such.

To make a 'verb', click the 'game' menu at the top and select 'add verb'.

Also on arrays, you do not have to 'make' them. In quest, you don't need to make any variables. Just 'set' them before you use them. For example, you don't need to make a status variable called 'channel', but it's an easy way of setting the variable at the start of the game and also you can set it to show on the right hand side when playing so you can easily see if it's working properly.

If you imagine a variable as a box, which contains either a number (mueric) or words (string). This box has a name on it. Now an array is a big box filled with other boxes, which are either strings or numerics themselves. The big box has a name and the little boxes inside are numbered, this number is called the index and it the bit that goes between the '[' and ']'.

Hope that helps a little. ;)

Sonny
27 Jul 2007, 11:56
Thanks Elex, yes that did help answer some of my questions. You and Tron have been a big help. If I could buy you a drink I would (even two or three ... lol).

Anxiously awaiting your demo as that would help greatly.

I will report back here as well with the results.

Thanx very much for your time,
Sonny

PS... sorry to post so many questions, but I have no other place to turn to with this and I am trying very hard at learning this, SO I REALLY DO THANK-YOU.

I know my questions are boring as well, but I am only trying things that the manual got me started in at the moment and most things were household items, so my experimenting is in that fold at the moment (such as chairs, doors, TV's, Ovens, Fridges, defibs, Sugar, Eggs, Bob etc.)

Elexxorine
27 Jul 2007, 21:45
No, it's ok. Asking questions is good cos you learn. Also me and Tron know a lot about quest (I know more than Tron, he admitted it a while ago). I also enjoy helping new people. I've been a bit busy today though so haven't got any more work done on the demo thing. I'm also going on holiday tomorrow so I'm posting what I've done so far:
create new game.
make a room.
make 'tv' object.
make 'remote' object.
on 'inventory' table for remote, set to take? yes, automatic.
create 'channel' status variable.
create 'change channel' verb.
in 'change channel':
add if (little '+if' button).
press top 'add' button on right.
select 'player has object'.
choose remote.
press top 'add' again.
this time select 'object is in current room'.
choose tv.
(make sure on the left hand side 'and' is selected.)
in the 'then' section:
click 'edit'.
open up the variable selection on the left.
select 'increment a numeric' (increment is a fancy word for add).
choose 'channel' from the drop down menu on the right.
leave the second box empty (it makes it add 1 if you leave it blank)
press the 'add if' button again.
press the top 'add' button.
in the right hand side:
in 'string 1', click the '%' button and choose 'channel'.
in 'string 2' write '7'.
press 'ok'.
in the 'then' section, click 'edit'.
open up the 'variables' section.
select 'set a numeric variable'.
choose 'channel'.
write '1' in the second box.
click 'ok'.

press 'ok'.
in the 'else' section:
click 'edit'.
print a message should already be open.
type a message in the right hand box, 'you can't do that.'
press 'ok'.
press 'ok' on the 'if' window.
now in the 'tv' object:
on the bottom right is a section labeled 'when a player looks at tv'.
click 'run a script'.
click 'edit' button to the bottom-right.
Next is making a series of 'if's to see what channel it is and printing a message saying what's on depending on the channel.

I'll give you the next bit when I've done it and I've got internet. :P