Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re:{3} Daft text adventure project

by jeroenes (Priest)
on May 29, 2001 at 17:28 UTC ( [id://83916]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Daft text adventure project
in thread Daft text adventure project

My mind is not in general compatibility mode, apparently.

Does this mean that you only allow the user to correct his input? Otherwise, the state of your program has changed since that step, because variables/objects have been altered. So you need to revoke these alterations.

Checking for return values is really simple in perl:

#This example is wearn out to the bone due to it's general use open FILE, 'data.txt' or die "Could not open data.txt: $!"; #in general, if function() returns either false or some true info: MAIN: { initialise_stuff; ask_user(); function( @_ ) or redo MAIN; .... }
Jeroen

Replies are listed 'Best First'.
Re: Re:{3} Daft text adventure project
by Tiefling (Monk) on May 29, 2001 at 17:48 UTC
    Ok. The code you provide is roughly how my creation program looks at the moment. (I don't want initialise redone anyway - some of that is going to be replaced by a function call, and the rest will doubtless be exported to a module, but for the interim, it just gets called once and does the dirty work.) However, what the desired state of affairs is, is that there are several functions, function1, function2, etc., which each set a different bunch of data (so that function1 sets %hash1, @array1 and $string1, for example), and the completed character is the union of all those sets, recast by a final function into a format the adventure will want to read. Each function is set up so that the player can choose a result (an arrangement of ability scores or a character race, in the currently operative functions), see what it looks like, and then accept it and proceed or reject it and go back to the top of the procedure. However, if a player, having chosen his ability scores, sees the races and wants to go back and re-arrange or re-roll his/her scores, we need to be able to call the ability-rolling procedure again, preferably preserving the old stats so that s/he can rearrange them, rather than utterly clobbering them as a re-start of the main program would do. Similarly, if, having seen the classes, the player wants a different race, we need to offer up the race procedure again.

    I get the feeling I'm not articulating this very well. Ah, well.

    Thanks again - Tiefling.
      Now I see. I think. Indeed you don't need fancy undo stuff for that. Just save all choices in a temp. variable, and let the user play around with it. Make sure to reset depending properties when certain choices are changed. Than only after a "Are you sure?" and "Are you really really sure?" you save those temps in the character and let the play begin.

      Hope this helps,

      Jeroen
      "We are not alone"(FZ)

        Exactly. What I'm looking for is a Way to Do the core program loop, so that completing a given character aspect goes down a step, and selecting 'back' takes you up a step, producing a new temporary flavour of the previous option which will ultimately replace the previous choice. (Note that while most computer RPGs use this kind of structure, the 3e character generator on the CD with the Player's Handbook doesn't, and I dislike it the more as a consequence. (Names are locked in first, believe it or not. Doh!))

        Tiefling

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://83916]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-29 09:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found