Hmmm …
You know, I’m gonna have to show this to Dan, I am …
As you’re probably very aware, by now, I’ve been slowly trying to make use of my by now ageing Performa for the past couple of months; to the point where it’s very frustrating that I’m not finding bits of extension code on there.
But at least — at the moment — I’ve got something that’s a usable retro Games machine.
Which is nice.
I’ve also been experimenting — in a very limited way — with AppleScript, Mac OS X’s onboard programming language.
Quite a long time ago, I had a ZX Spectrum, the old Sinclair home computer.
And, role playing gamer and games master that I was, it seemed very logical to me to use it to automate simple little things; mapmaking, for example, or treasure generating.
Or, in the case of the one programme I actually did write, character generating; for fifth edition “Tunnels and Trolls”, so you know.
Now the Spectrum and the programme I did are long since gone, but — and this is sadly geeky, I know — I’ve still got the “Tunnels and Trolls” rulebook.
So I thought, as I’ve got time on my hands, I thought I’d try re-writing that character generation programme; although I’m told they’re called scripts, these days.
display dialog "Would you like to generate a T & T character?" buttons {"No", "Yes"} default button 2
if the button returned of the result is "No" then
say "Ok, that’s cool." using "Vicki"
else
set numberslist to {3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18}
set Strength1 to some item of numberslist
set Intelligence1 to some item of numberslist
set Luck1 to some item of numberslist
set Constitution1 to some item of numberslist
set Dexterity1 to some item of numberslist
set Charisma1 to some item of numberslist
end if
set x to 0
set y to 0
set z to 0
if Strength1 is greater than 12 then set x to Strength1 - 12
if Strength1 is less than 9 then set x to 9 - Stength1
if Intelligence1 is greater than 12 then set x to Intelligence1 - 12
if Intelligence1 is less than 9 then set x to 9 - Intelligence1
if Luck1 is greater than 12 then set x to Luck1 - 12
if Luck1 is less than 9 then set x to 9 - Luck1
set CombatAdds to x + y + z
say "Your Strength is" using "Vicki"
say Strength1 using "Vicki"
say "Your Inteligence is" using "Vicki"
say Intelligence1 using "Vicki"
say "Your Luck is" using "Vicki"
say Luck1 using "Vicki"
say "Your Constitution is" using "Vicki"
say Constitution1 using "Vicki"
say "Your Dexterity is" using "Vicki"
say Dexterity1 using "Vicki"
say "Your Charisma is" using "Vicki"
say Charisma1 using "Vicki"
if CombatAdds is greater than 0 then say "You have a combat bonus of plus" using "Vicki"
if CombatAdds is greater than 0 then say CombatAdds using "Vicki"
if CombatAdds is less than 0 then say "You have a combat modifier of minus"
if CombatAdds is less than 0 then say CombatAdds
set Gold to (some item of numberslist) * 10
say "You have " using "Vicki"
say Gold using "Vicki"
say " gold pieces" using "Vicki"
Right, now this is a provisional version.
Very provisional.
But let me try and explain.
“Tunnels and Trolls”, like many games of the era, used dice — bog standard six sided ones, that you get in any backgammon or “Monopoly” set — to generate a character’s statistics; Strength, Intelligence, Luck, and the rest of them.
Those are the number’s used to determine if a character can roll a large boulder away from a cave entrance, for example, or if he or she can solve a puzzle, survive a disease; what have you.
That’s what the first part of the script does, from “display dialog” to “end if”; generates those numbers.
The part from “set x to 0” to “if CombatAdds is less than 0 then say CombatAdds” works out the newly generated character’s combat adds; a bonus — or negative number — that tells you how much extra or less damage your new character does in combat.
The last few lines are simple; they tell you how much money you’re new character stats with.
Right, now …
Obviously, I’ll be modifying this, other the next few week; I’d like for ti to generate maybe elves and dwarves, as well.
For those of you who want to be picky, this script was written with Script Editor 2.2.1, on my Mac Mini, running Mac OS X 10.5.7.
And I’m also going to see if I can’t get Script Editor to send the results to Text Edit; it would be nice to be able to print the results out, rather than just have them read out. As nice as Vicki is …
No comments:
Post a Comment