Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List out of scope?
#11
What you're doing sounds very similar to something I wrote a few years ago: http://dnd.nilamo.com/ (it's javascript, so if you look at the source it might give some ideas on how you can write yours)

It rolls a d6 4 times, rerolls all ones (over and over until they're not 1s anymore), and adds up the highest 3 rolls. You can hover over any of the numbers to see the actual "rolls" that went into generating that number. It's a matrix of roll results, because the way we did character generation is that you got to pick any row/column and use those values for your character. We also had another modification, such that if none of the values were 18, you changed the lowest value to 18. So it was very common in our group for 15-16 to be your lowest stat.
Reply
#12
Although Larz60+ has given you the information to solve this yourself (which is excellent), I strongly recommend you use for loops instead of while loops, and even use (list) comprehensions instead of append when possible.
Reply
#13
Quote:Wish I could edit my original post to reflect this stuff instead of reposting. :(
I can assure you, you dont want to do that. No one who has read this post already checks for edits. Most likely would get passed by without notice. But now that you have 5 posts you can edit your own posts up to 48 hours.
Recommended Tutorials:
Reply
#14
(Nov-07-2016, 08:57 PM)micseydel Wrote: Although Larz60+ has given you the information to solve this yourself (which is excellent), I strongly recommend you use for loops instead of while loops, and even use (list) comprehensions instead of append when possible.

Thanks for the suggestion, I'll look it up and try to work that into my code. Right now I'm just diving in head first to see what all I remember from my previous (limited) programming experiences.

(Nov-07-2016, 10:21 PM)metulburr Wrote: I can assure you, you dont want to do that. No one who has read this post already checks for edits. Most likely would get passed by without notice. But now that you have 5 posts you can edit your own posts up to 48 hours.

OK, good to know.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to create a variable only for use inside the scope of a while loop? Radical 10 1,711 Nov-07-2023, 09:49 AM
Last Post: buran
  Library scope mike_zah 2 845 Feb-23-2023, 12:20 AM
Last Post: mike_zah
  Scope of variable confusion Mark17 10 2,851 Feb-24-2022, 06:03 PM
Last Post: deanhystad
  Variable scope issue melvin13 2 1,536 Nov-29-2021, 08:26 PM
Last Post: melvin13
  Variable scope - "global x" didn't work... ptrivino 5 3,039 Dec-28-2020, 04:52 PM
Last Post: ptrivino
  Python Closures and Scope muzikman 2 1,812 Dec-14-2020, 11:21 PM
Last Post: muzikman
  Block of code, scope of variables and surprising exception arbiel 8 3,422 Apr-06-2020, 07:57 PM
Last Post: arbiel
  Help with Global/Coerced Variable (Understanding Scope) Rev2k 6 3,510 Jan-09-2020, 03:43 AM
Last Post: Rev2k
  Solving a scope issue profconn1 4 2,592 Nov-01-2019, 07:46 PM
Last Post: profconn1
  Namespace and scope difference Uchikago 9 4,603 Jul-03-2019, 03:36 PM
Last Post: Uchikago

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020