Author Topic: Telephones  (Read 53678 times)

0 Members and 1 Guest are viewing this topic.

Offline scott_furphies

Telephones
« on: December 11, 2020, 04:31:44 PM »
Hi all,
I was wondering if anyone has had a creative solution to including telephones in your game. I've been analysing the Police Quest 2 phone script for ideas.

Originally I was going to use a pop-up keypad, but thought it would be simpler to just have the user input the number into the text parser. This is pretty clunky so far, considering it's a fairly simple concept!

ideally I want the user experience to go:
INPUT: pick up phone
(ego sits in the chair and picks up the phone, only accepting either numbers or "hang up" to return to normal roomscript)
DIAL: (anynumber or specific number)
results--phone call script or random wrong number script.
if the user inputs a word instead of a number at this point you get a unique error message for this situation

I get that the number must actually be a string as the interpreter doesn't like eight digit numbers!

Any suggestions would be much appreciated!





Offline Doan Sephim

Re: Telephones
« Reply #1 on: December 12, 2020, 09:03:33 AM »
I like the idea of a graphical input, like a number pad. Then, instead of checking a large number against their input, you could check each number against 8 individual variables (or just an array of variables more likely)

Alternatively, if you want to stick with inputting a number via typing, you could prompt the first 3 numbers, then the last 4, and check those 2 inputs as they would be more manageable number sizes.

Offline Kawa

Re: Telephones
« Reply #2 on: December 12, 2020, 10:20:09 AM »
What I would do is take a page from the LSL2 copy protection.

When the player types "pick up phone", ego sits down and picks up the phone, you could pop up a window just like the "Enter input" prompt, but it's not the same. This gives you a string buffer with the thing that was entered. StrCmp the input against the number you want, itself as a string. If it matches, go off. If it matches "hang up", that's easy. Anything else, you can probably assume is an incorrect number.

You could ensure that it's a number by checking the first character of the input. If *that* is between 0x30 and 0x39, it's likely the rest of the input was a number. If it's not, and it might be "hang up", you could make that a little more flexible with an in-place Parse and Said so that things like "hang up the phone" can also work. Ask me how that might be done.

Personally, if it's a text parser game, I would expect the phone to be controlled by keyboard -- pick up phone, 209-6838989, hang up.

I like the idea of a graphical input, like a number pad. Then, instead of checking a large number against their input, you could check each number against 8 individual variables (or just an array of variables more likely)
I was going to say something about multiplying the number so far by ten and adding the button's value, but that'd leave you with only five very range-limited digits. So I looked into LSL1 and found it uses arrays of numbers: (local ajax = [5 5 5 8 0 3 9 0 0 0])

Offline scott_furphies

Re: Telephones
« Reply #3 on: December 12, 2020, 03:15:01 PM »
Awesome, thanks for the suggestions, I'm realising there's a lot of options of how to do this, using an array is something I hadn't considered!

I spend 99% of my time drawing background images and animations, it's exciting when coding challenges like this come up. I'm still pretty torn between keyboard input (it is a parser game) and mouse input with a graphical keypad. Something to work on this week!

Offline Kawa

Re: Telephones
« Reply #4 on: December 12, 2020, 03:38:28 PM »
Pro mode: pop up a graphical keypad, have the cursor respond to the arrow keys. Extra pro: do that and respond to number keys.

Offline scott_furphies

Re: Telephones
« Reply #5 on: December 12, 2020, 04:51:16 PM »
that would be clearly better! but probably a bit advanced for me at this stage, I will probably work on a basic solution and go back to it when I have a better understanding.

on that note - how do I get an input window which doesn't use the text parser?

Offline Kawa

Re: Telephones
« Reply #6 on: December 12, 2020, 04:56:37 PM »
Same way the parser does: (= strLen (EditPrint @inputStr 45 "Enter input" #at -1 150))

Offline scott_furphies

Re: Telephones
« Reply #7 on: December 12, 2020, 08:54:04 PM »
thanks Kawa!

Offline scott_furphies

Re: Telephones
« Reply #8 on: December 13, 2020, 03:15:39 AM »
The solution I'm going with is so stupid it will likely get me kicked out of Ken Williams' hot tub key party.

I couldn't figure out how to bypass the parser to get a string input, so I decided it would actually be faster to just draw a damn phone and slap some buttons on it. Mouse-driven graphical interface for the win!

After messing around with trying to concatenating strings, pushing to arrays (all things that would be pretty straight-forward in javascript or C++) I decided to go with a pretty basic and lazy solution which works pretty well.

instead of checking against the phone numbers I want to use it checks against the sum of the digits in the phone number. eg 6+3+0+5+9+1+2=26

It...Works?

Offline Kawa

Re: Telephones
« Reply #9 on: December 13, 2020, 07:57:39 AM »
Ah, simple hashing. Which means 630-5912 is the same phone number as 360-1259.

Offline scott_furphies

Re: Telephones
« Reply #10 on: December 13, 2020, 03:17:17 PM »
Yeah, a pretty dumb solution, something I will get back to.
I haven't used for loops in SCI yet, which is probably the better option.

Offline lskovlun

Re: Telephones
« Reply #11 on: December 13, 2020, 06:16:16 PM »
This reminds me of that easter egg in SQ6 that to the best of my knowledge hasn't been described online.
Type Steve Conrad's girlfriend's phone number and get a personal message.

To conceal the number, Steve used partial sums.

Offline scott_furphies

Re: Telephones
« Reply #12 on: December 13, 2020, 06:23:39 PM »
Sometimes the solution to a problem is super obvious the next day!

turns out it's not that hard to use a while loop to iterate through both arrays to match them.

Also a combination of mouse and keyboard control seems to work fine! I take away player control and the text parser while you're close up on the telephone.

Offline Kawa

Re: Telephones
« Reply #13 on: December 13, 2020, 07:26:53 PM »
turns out it's not that hard to use a while loop to iterate through both arrays to match them.
Congratulations. I do believe that's just about how LSL1VGA does it.

Offline scott_furphies

Re: Telephones
« Reply #14 on: December 16, 2020, 05:00:44 AM »
I'm glad I ended up going with the graphic interface after all!


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.063 seconds with 22 queries.