by Roody_Yogurt » Sat Nov 26, 2011 2:33 pm
Of course, the same idea can be applied to things other than "YES" and "NO" answers in the game. Looking at HxE and my own files, I am reminded that I still haven't polished a library contribution I meant to add at some point. It's called "opportune.h", and it's basically a simplified version of "Informal Questions" (in fact, some of the IQ code has been left in there as someone might still want it).
The point of this library is for all of the times you want to have a 1 turn window open for somebody to do something. Of course, there are other ways to handle it, but the purpose of this method is to keep your code clean and easy to read.
The code so far:
Code: Select all
global current_opp
! A fuse so that each question is only answerable for one turn
! opp_window = short for "opportunity window"
! changed the name of the fuse so it'd sound more
! dual-purpose
fuse opp_window
{}
event opp_window
{
if not self.tick
current_opp = 0
}
!\ ! the old code in case someone wants any questions
! a question class so to help organize our questions
class Question
{}
question egress
{
long_desc
"Are you sure you're mentally and otherwise prepared to meet up with an egress?"
}
Started like:
NewQuestion(egress)
\!
routine NewQuestion(question)
{
current_opp = question
run question.long_desc
Activate (opp_window, 2)
}
routine NewOpp(opportunity)
{
current_opp = opportunity
Activate (opp_window, 2)
}
class opp
{}
! some sample opportunities
opp busted
{}
opp takealook
{}
So, in my WIP, it is possible to have an object hit you in the face (I think I say "chin"). I set the "busted" opportunity, then in my chin object, I have this code:
Code: Select all
object chin "chin"
{
article "your"
noun "chin"
part_of you
long_desc
{
if current_opp = busted
"Aw, it'll be okay."
else
"It is your chin."
return true
}
}
Now, after somebody does the chin-smashing action, if they look at their chin right away, they get the reassuring "Aw, it'll be okay."
So yeah, there are a lot of uses for something like this (I hope).
Of course, the same idea can be applied to things other than "YES" and "NO" answers in the game. Looking at HxE and my own files, I am reminded that I still haven't polished a library contribution I meant to add at some point. It's called "opportune.h", and it's basically a simplified version of "Informal Questions" (in fact, some of the IQ code has been left in there as someone might still want it).
The point of this library is for all of the times you want to have a 1 turn window open for somebody to do something. Of course, there are other ways to handle it, but the purpose of this method is to keep your code clean and easy to read.
The code so far:
[code]
global current_opp
! A fuse so that each question is only answerable for one turn
! opp_window = short for "opportunity window"
! changed the name of the fuse so it'd sound more
! dual-purpose
fuse opp_window
{}
event opp_window
{
if not self.tick
current_opp = 0
}
!\ ! the old code in case someone wants any questions
! a question class so to help organize our questions
class Question
{}
question egress
{
long_desc
"Are you sure you're mentally and otherwise prepared to meet up with an egress?"
}
Started like:
NewQuestion(egress)
\!
routine NewQuestion(question)
{
current_opp = question
run question.long_desc
Activate (opp_window, 2)
}
routine NewOpp(opportunity)
{
current_opp = opportunity
Activate (opp_window, 2)
}
class opp
{}
! some sample opportunities
opp busted
{}
opp takealook
{}
[/code]
So, in my WIP, it is possible to have an object hit you in the face (I think I say "chin"). I set the "busted" opportunity, then in my chin object, I have this code:
[code]
object chin "chin"
{
article "your"
noun "chin"
part_of you
long_desc
{
if current_opp = busted
"Aw, it'll be okay."
else
"It is your chin."
return true
}
}
[/code]
Now, after somebody does the chin-smashing action, if they look at their chin right away, they get the reassuring "Aw, it'll be okay."
So yeah, there are a lot of uses for something like this (I hope).