if (not Got(small_oil_cartridge)) {
msg ("<br/>Without oil, you cannot light this lantern. It is essentially useless right now. <br/>")
}
else if (Got(small_oil_cartridge)) {
msg ("<br/>After inserting an oil cartridge into the slot, you gently close the opening and then gingerly turn the knob a few times until you hear a soft click. Moments later, a bright glow begins emitting from the old contraption. Inside, an orange flame burns brightly, which can now act as a guide through dark places. An orange glow surrounds you. <br/>")
SetObjectLightstrength (old_lantern, "strong")
use_container ("small_oil_cartridge")
}
Note
Quest counts each player input as a turn. If the player spending 10 turns typing commands that are not recognised, that is still 10 turns.
TinFoilMkIV wrote:In the tutorial the turn script itself is just in the general objects tree, it's not actually inside any rooms at all, which is where it needs to be if you want it to be able to apply at any point in the game, as placing it inside a room will make it only active inside that room.
That being said turn scripts can be a bit tricky depending on what exactly you want out of them, and it's likely you'll want something a bit more than just the basic functionality. The problem here is that a standard turn scrip that's active goes off every time the player enters an input no matter what it is, even if it's an invalid command, the turn script still goes off. So you might see how that could be a problem with a time limited light source that loses fuel even when taking actions that shouldn't take an actual in game turn, or even a typo.
I'm not really sure the best way to go about it, but you will need a way for the game to determine what actions count as an actual game turn, and then use an attribute to let it know when that turn is actually happening. The first thing that comes to mind for me is to add code to any verb or command that qualifies as a full turn action, and have that set an attribute to signify that a turn has passed. Then in the turn script itself have it start with an 'if' statement that checks to see whether this attribute has been set, if yes, then do your normal turn stuff that needs to be done, then set the turn variable back off, and if not, then do nothing. This way you have control over what inputs count as an actual turn, although you then have to make sure every action that should be a turn actually counts as one.
The Pixie wrote:That is what I meant, tho it's a good thing you clarified because looking back I can see I wrote that really poorly."TinFoilMkIV"
In the tutorial the turn script itself is just in the general objects tree, it's not actually inside any rooms at all, which is where it needs to be if you want it to be able to apply at any point in the game, as placing it inside a room will make it only active inside that room.
If it is in the general tree it will run whatever room the player is in, which what neonayon wants.
Hmm, so that sounds incredibly complicated. I don't mind the turn-scripts including false commands or mistypes, and I figure putting the turn-script in the "game.object" would likely make it global. I've just never used a turn-script before. They are little intimidating. Timers are easy xD Maybe I should just go with one of those.
SetTurnTimeout (15) {
msg ("<br/>The lantern begins to flicker before the oil cartridge is finally used up. Moments later, the lantern dies. <br/>")
SwitchOff (old_lantern)
DisableTurnScript (small_oil)
}
SetTurnTimeout (15) {
msg ("<br/>The lantern begins to flicker before the oil cartridge is finally used up. Moments later, the lantern dies. <br/>")
SwitchOff (old_lantern)
DisableTurnScript (medium_oil)
}
SetTurnTimeout (35) {
DisableTurnScript (oil)
SwitchOff (old_lantern)
msg ("<br/>The lantern begins to flicker before the oil cartridge is finally used up. Moments later, the lantern dies. <br/>")
}
if (not Got(oil_cartridge)) {
msg ("<br/>Without oil, you cannot light this lantern. It is essentially useless right now<br/>")
}
else {
if (Got(oil_cartridge)) {
msg ("<br/>After inserting an oil cartridge into the slot, you gently close the opening and then gingerly turn the knob a few times until you hear a soft click. Moments later, a bright glow begins emitting from the old contraption. Inside, an orange flame burns brightly, which can now act as a guide through dark places. An orange glow surrounds you. <br/>")
EnableTurnScript (oil)
SetObjectLightstrength (old_lantern, "strong")
RemoveObject (oil_cartridge)
}
}
if (IsSwitchedOn (old_lantern)) {
msg ("<br/>The lantern is already shining brightly; no need to use a cartridge now.. <br/>")
}
else {
SetTurnTimeout (this.lifetime) {
msg ("<br/>The lantern begins to flicker before the oil cartridge is finally used up. Moments later, the lantern dies. <br/>")
SwitchOff (old_lantern)
SetObjectLightstrength (old_lantern, "")
}
SwitchOn (old_lantern)
SetObjectLightstrength (old_lantern, "strong")
destroy(this.name)
}
HegemonKhan wrote:err... my apologies for any confusion, I totally forgot that, that command~method~whatever (SetTurnTimeOut) existed, laughs.
err... is the 'SetTurnTimeout' a method of the Turnscript? Or, does the 'SetTurnTimeout' create a Turnscript? It's been so long for me, I'm now confused. The quest wiki doc, doesn't show the 'SetTurnTimeout' as a method~Attribute of a Turnscript Element... but I thought as I'm trying to remember, if this was a method~Attribute of a Turnscript, or not. I know that there's a similar Function~method for the Timer... maybe the wiki just is missing it, or it's not a method~Attribute of the Turnscript.
if (GetBoolean(Xanadu, "healthy")) {
Xanadu.sickcount = 0
}
else {
if (Xanadu.sickcount = 2) {
msg ("----<br/>Your mouth, tongue, and throat have this odd, tingling sensation.")
}
else if (Xanadu.sickcount = 5) {
msg ("----<br/>Aside from the tingly sensation in your mouth and throat, it now feels like little, drunk gymnasts are doing flips and twists in your gut. In doing so, those little gymnasts are somehow also playing an odd assortment of instruments that make some of the strangest gurgling, burbling, and sloshing sounds you have ever heard. Perhaps you should find your way to a restroom?")
}
else if (Xanadu.sickcount = 8) {
msg ("----<br/><i>'Oh, Dear Eight Pound, Six Ounce, Newborn Baby Jesus, in your golden, fleece diapers...'</i> you mutter as you begin your prayers. The twirling in your stomach has escalated to an all out riot. Whatever is in there, is fighting violently to get out. Your esophageal and anal sphincters are now on all out 'pucker mode'. Sweat has beaded on your brow. It is a cold and unwelcome sweat. You really, really, really need to find a restroom.")
}
else if (Xanadu.sickcount = 12) {
msg ("---<br/>You can no longer swallow your bathroom pride...<br/><br/>You drop your pants immediately where you stand. Before they hit the floor, the eruptions begin. There is so much leaving your body (from both ends), you quickly dehydrate and become disoriented. You stumble around, slipping in wet puddles. You remember dancing lights and spinning rooms. You stumble into a cold room and pass out...<br/>---")
SetObjectFlagOn (Xanadu, "healthy")
AddToInventory (rotten food)
play sound ("fart.wav", false, false)
MoveObject (Xanadu, Prison Cell)
}
else {
if (game.pov.parent = farthest stall) {
play sound ("fart.wav", false, false)
msg ("---<br/>With your knees crossed coupled with your difficulty in standing up straight, you are having a hard time getting your pants down.<br/><br/>Just in the nick of time, you do get your pants opened up and you drop them to the floor...<br/><br/>Before you can sit down, however, the dam breaks and the flood gates open. At first, it just sounds like a high pressure fire hose. Sprinkled in are some odd toots and squeaks as the sulfurous emission continues. At the tail end (no pun intended) of your fecal display, the cacophony of noises erupts into a crescendo of honks, bloots, ka-phroops, slurps, and fizzles. Just when you thought the misery was over, the vomiting begins. The projectile barf flies forth in a fancy array of colors. The explosiveness of it all is enough to make Mt. Pinatubo blush. You hurl, spew, chowdergargle, and blow chunks. You upchuck one last time and wipe your mouth on your sleeve. At least you are feeling a little better now.<br/><br/>You wipe your bleary, wet eyes and take in your surroundings.<br/>---")
wait {
msg ("---<br/>Wow. Disgusting. I can't even describe how unclean this stall is. There are colors and smells and textures in here that go beyond rational explanation. Is it possible to hold this much filth in one human stomach? Wait... You don't remember eating anything that was neon green. How did shit get on the ceiling? <br/><br/>Anyway, you sheepishly back out of the stall, disappear from the restroom, and sneak off down the hallway to avoid embarrassment. Although you feel sorry for whatever poor soul has to clean this up, you hope it gets done pretty quickly. Ick...<br/>---")
DisableTurnScript (sickturnscript)
MoveObject (rotten food, Item Warehouse 1)
IncreaseScore (10)
MoveObject (Xanadu, Long Hallway)
UnlockExit (JCLock)
SetObjectFlagOn (Xanadu, "healthy")
SetObjectFlagOn (farthest stall, "unclean")
MoveObject (janitors cart, Filthy Restroom)
}
}
}
Xanadu.sickcount = Xanadu.sickcount + 1
}
if (IsSwitchedOn (old_lantern)) {
msg ("<br/>The lantern is already shining brightly; no need to use a cartridge now.. <br/>")
}
else {
SetTurnTimeout (this.lifetime) {
msg ("<br/>The lantern begins to flicker before the oil cartridge is finally used up. Moments later, the lantern dies. <br/>")
SwitchOff (old_lantern)
SetObjectLightstrength (old_lantern, "")
}
SwitchOn (old_lantern)
SetObjectLightstrength (old_lantern, "strong")
destroy(this.name)
}
if (not old_lantern.parent = player) {
msg("The cartridge is for use on a lantern, and you are not carrying a lantern.")
}
else if (IsSwitchedOn (old_lantern)) {
msg ("<br/>The lantern is already shining brightly; no need to use a cartridge now. <br/>")
}
else {
msg ("<br/>You put the cartridge in the lantern and it starts to glow brightly. <br/>")
SetTurnTimeout (this.lifetime) {
msg ("<br/>The lantern begins to flicker before the oil cartridge is finally used up. Moments later, the lantern dies. <br/>")
SwitchOff (old_lantern)
SetObjectLightstrength (old_lantern, "")
}
SwitchOn (old_lantern)
SetObjectLightstrength (old_lantern, "strong")
destroy (this.name)
}
<!--Saved by Quest 5.6.5783.24153-->
<asl version="550">
<include ref="English.aslx" />
<include ref="Core.aslx" />
<game name="lantern">
<gameid>f6e3d45a-fbf4-40a1-91e7-7aa506071d85</gameid>
<version>1.0</version>
<firstpublished>2015</firstpublished>
<feature_lightdark />
</game>
<object name="room">
<inherit name="editor_room" />
<description>The first room</description>
<object name="player">
<inherit name="editor_object" />
<inherit name="editor_player" />
</object>
<object name="old_lantern">
<inherit name="editor_object" />
<take />
<alias>lantern</alias>
</object>
<object name="cart">
<inherit name="editor_object" />
<feature_usegive />
<use type="script"><![CDATA[
if (not old_lantern.parent = player) {
msg ("The cartridge is for use on a lantern, and you are not carrying a lantern.")
}
else if (IsSwitchedOn (old_lantern)) {
msg ("<br/>The lantern is already shining brightly; no need to use a cartridge now. <br/>")
}
else {
msg ("<br/>You put the cartridge in the lantern and it starts to glow brightly. <br/>")
SetTurnTimeout (this.lifetime) {
msg ("<br/>The lantern begins to flicker before the oil cartridge is finally used up. Moments later, the lantern dies. <br/>")
SwitchOff (old_lantern)
SetObjectLightstrength (old_lantern, "")
}
SwitchOn (old_lantern)
SetObjectLightstrength (old_lantern, "strong")
destroy (this.name)
}
]]></use>
<take />
<lifetime type="int">5</lifetime>
</object>
<exit alias="south" to="room2">
<inherit name="southdirection" />
</exit>
</object>
<object name="room2">
<inherit name="editor_room" />
<dark />
<description>The second room</description>
<darkroomdescription>This room is dark.</darkroomdescription>
<exit alias="north" to="room">
<inherit name="northdirection" />
</exit>
</object>
</asl>
if (not old_lantern.parent = player) {
msg("The cartridge is for use on a lantern, and you are not carrying a lantern.")
}
else if (IsSwitchedOn (old_lantern)) {
msg ("<br/>The lantern is already shining brightly; no need to use a cartridge now. <br/>")
}
else {
msg ("<br/>You put the cartridge in the lantern and it starts to glow brightly. <br/>")
SetTurnTimeout (this.lifetime) {
msg ("<br/>The lantern begins to flicker before the oil cartridge is finally used up. Moments later, the lantern dies. <br/>")
SwitchOff (old_lantern)
SetObjectLightstrength (old_lantern, "")
}
if (not old_lantern.parent = player) {
msg ("<br/>The cartridge is for use on a lantern, and you are not carrying a lantern.<br/>")
}
else if (IsSwitchedOn (old_lantern)) {
msg ("<br/>The lantern is already shining brightly; no need to use a cartridge now. <br/>")
}
else {
msg ("<br/>After inserting an oil cartridge into the slot, you gently close the opening and then gingerly turn the knob a few times until you hear a soft click. Moments later, a bright glow begins emitting from the old contraption. Inside, an orange flame burns brightly, which can now act as a guide through dark places. An orange glow surrounds you.<br/>")
SetTurnTimeout (this.lifetime) {
msg ("<br/>The lantern begins to flicker before the oil cartridge is finally used up. Moments later, the lantern dies. <br/>")
SwitchOff (old_lantern)
SetObjectLightstrength (old_lantern, "weak")
}
SwitchOn (old_lantern)
SetObjectLightstrength (old_lantern, "strong")
destroy (this.name)
}