10-24-2007
Quote:
Originally Posted by
Perderabo
This is quite a mess. I don't see an easy way to fix it. I think a complete redesign is in order. The crux of your problem is code like:
player1hand=`deal_hole`
The shell must launch a sub-shell to process the `deal_hole` part. Within this subshell you mark some cards as being delt. Then the subshell exits and the main shell does know which cards were delt. You can't write a function that modifies global data and then invoke it in a subshell.
Good info Perderabo...
What would you suggest to keep things in order? Could I put the entire "play" code (meaning the part that is dealing and whatnot) into a single function?
I am not really strong with arrays, but if you could point me in the right direction I can probably figure it out.
Edit: Putting the play section to a function did not work, but I now see what you are talking about with the $player1hand issue spawning a subshell. What's a better way to save the player's hands so they can be referenced at the end of the script?
Edit2: Not assigning the output of the function (such as deal_hole) to a variable solves the problem, but I would like a way to reference the output later... is it possible?
Edit3: Ok, here's an idea... I'm having trouble finding if this is possible, but could I run the 'deal_hole' function and have the output send to stdout and then also redirected to a file that could be called later?
Last edited by earnstaf; 10-24-2007 at 03:49 PM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I use a wget background process to downlaod a php file on my site.
Is there any way i can do this without downloading a file
like updating right from the shell itself? (0 Replies)
Discussion started by: mikey1090
0 Replies
2. Linux
Well Acording to my job...
Anyhelp plz.
I need some basic scripting stuff. (3 Replies)
Discussion started by: Irish Jimmy
3 Replies
3. Shell Programming and Scripting
Any ideas on whats the best way to form a hangman game via bash shell. (0 Replies)
Discussion started by: immyakram
0 Replies
4. Shell Programming and Scripting
Okay so I'm making a simple text based game that branches into different scenarios. By branching I mean branching off into whole different files with that part of the game in it. I got tired of working on scenario 1 so I'm working on scenario 2. As I get started and try to test it, I get an... (3 Replies)
Discussion started by: lemonoid
3 Replies
5. Homework & Coursework Questions
Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!
1. The problem statement, all variables and given/known data:
I have written a script for a dice game that: (1) tells user that each of the 2 die are 6 sided (Spots=6); (2)... (3 Replies)
Discussion started by: LaurenRose
3 Replies
6. Shell Programming and Scripting
GitHub - deepgrace/tetris: Tetris implementation in all kinds of Programming Languages
Usage: bash Tetris_Game ] ] ] ]
Range:
#!/bin/bash
# Tetris Game // The Art Of Shell Programming
box0=(4 30)
box1=(4 30 4 32)
box2=(4 30 5 32)
box3=(4 28 4 30 4 32)
box4=(4 28 4 30... (69 Replies)
Discussion started by: complex.invoke
69 Replies
7. Shell Programming and Scripting
When I run the following script at the bottom it say cards remaining=44...It should be=35.
Can anyone tell me what I'm doing wrong. I've spent hours trying to get this to work and I can't go any further until this part works. thank you in advance
Cogiz
#!/bin/bash
# Date="November, 2016"
#... (2 Replies)
Discussion started by: cogiz
2 Replies
8. Shell Programming and Scripting
Hello guys I'm new to shell scripting and I need to make a game using shell script. I want to know if it is possible for me a total noob to shell scripting to make this game.
The game concept is simple:
First thing when you launch the script you get a menu in which you select if you want to... (3 Replies)
Discussion started by: Othmane
3 Replies
9. Shell Programming and Scripting
Hello,
I have a problem with the /etc/rc.d/init.d script to automatically update STEAM GAME ARK. I've converted 3 scripts into one, but something does not work correctly ...
The problem is in the file latestavailableupdate.txt / line 36/39. It think the problem is with script, it wrongly... (2 Replies)
Discussion started by: kshishu
2 Replies
10. Programming
Hi everyone, I need some help seriously. The game is in text mode. It will be based on questions and answers and simple commands. A menu containing options of the game including:
1-Create a new player.
2-Identify as existing player.
3-Launch a new game: this action opens a new game for an... (1 Reply)
Discussion started by: NaimZero
1 Replies
TERM(1) General Commands Manual TERM(1)
NAME
term - turn PC into a dumb terminal [IBM]
SYNOPSIS
term [baudrate] [parity] [bits_per_character] [-dial_string] [device]
EXAMPLES
term 2400 # Talk to modem at 2400 baud
term 1200 7 even # 1200 baud, 7 bits/char, even parity
term 8 9600 /dev/tty01
# 9600 baud, 8 bits/char, no parity, use tty01
term -atdt12345 /dev/tty01
# Start with a command to dial out
DESCRIPTION
Term allows MINIX to talk to a terminal or modem over RS232 port 1. The program first sets the baudrate, parity and character length, and
then forks. The parent sits in a loop copying from stdin (usually the console's keyboard), to the terminal or modem (/dev/tty00). The
child sits in a loop copying from the terminal or modem (/dev/tty00) to standard output. Thus when RS232 port 1 is connected to a modem,
every keystroke typed on the keyboard is sent to the modem, and every character arriving from the modem is displayed. Standard input and
output may be redirected, to provide a primitive file transfer program, with no checking. Any argument that starts with a minus ('-') is
sent out to the modem, usually to dial out. Term accepts several commands that are formed by typing the escape character, CTRL-], and a
letter. Type CTRL-]? to see a list of commands. The subshell command is very important, it allows you to type in a ZMODEM command to
transfer data. Do not quit term to do this, or your modem line will be reset! Term keeps the modem line open on file descriptor 9 while
running the subshell, so you can type
<&9 >&9
at the end of your ZMODEM command to connect it to the modem.
Important note: to use term, it is essential that /etc/ttytab is configured so that there is no shell hanging on /dev/tty01. If there is,
both the shell and term will try to read from /dev/tty01, and nothing will work.
SEE ALSO
rz(1), sz(1).
TERM(1)