Photosensitive Lamp

This is probably going to be an easy fix, but I'm just not seeing it. I've tried all the permutations I can think of.

I have an object 'lamp' that can light up rooms(obviously), so I've ticked the relevant box on the features tab.
On the 'Light/Dark' tab, I've ticked the box, to say 'This object is a lightsource' and set the 'Brightness' to strong.

Ok, that's the easy bit, the problem:

I want this lamp to be photosensitive, ie to come on only if the room is 'dark', I don't want any switches or batteries. I figured the lamp would therefore be on all the time, and all I'd need to do, would be to change the lamps 'Look at' description.
If the player is in a lit room, the lamp is off, if the player is in a dark room, the lamp is on.

An modern lamp {if game.pov.parent.dark=True:The lamp is on.}{if game.pov.parent.dark=False:The lamp is off.}

As I've said, I'm scratching my head, trying to get it to display correctly and hope someone can help.


Try:

A modern lamp. {either game.pov.parent.dark:The lamp is on.:The lamp is off.}

The if directive is a bit more restricted and can only copy with one dot, not three.


I've just tried that Pixie, in the room that's lit, it just prints "A modern lamp", but in the room that's 'dark', it prints
"A modern lamp. The lamp is on.:The lamp is off.


If the lamp doesn't get moved, you could use the name of the room instead of game.pov.parent, then you've only got one dot.
Or if all else fails, make a script attribute rather than relying on the text processor.


Yeah @mrangel, I've had to run a script, thought I could've done it through the text processor.
Is there a way I can have the message printed on the same line, at the moment it reads:

A modern lamp.
The lamp is on.

as opposed to:

A modern lamp. The lamp is on.

Normally, the enter button.

This is a more serious example.

msg ("Hi.<br/>My<br/>Name is<br/>JMNE.")

concatenation (within a/your/as-a Script Attribute):

string_variable = "hi"
if (player.alias = "HK") {
  string_variable = string_variable + ", " + player.alias + "! How are you doing?"
} else {
  string_variable = string_variable + ", nice to meet you."
}
msg (string_variable)

// results/output (on one/same line):

hi, HK! How are you doing? // if player.alias = "HK"
// or:
hi, nice to meet you. // if not player.alias = "HK"


K.V.

There was a tiny error in the code Pix posted.

Try this:

A modern lamp. {either game.pov.parent.dark:The lamp is on.|The lamp is off.}

I just tested it. It works.


dark rooms (for DrAgon)

You are in a Hall.
You can see a lamp.
You can go south.

> look at lamp
A modern lamp. The lamp is on.


K.V.

Is there a way I can have the message printed on the same line

image

OutputTextNoBr ("A modern lamp.")
if (game.pov.parent.dark) {
  msg ("  The lamp is on.<br/>")
}

> look at lamp
A modern lamp. The lamp is on.


K.V.

Or...

JS.addText ("A modern lamp.")
if (game.pov.parent.dark) {
  JS.addText ("  The lamp is on.<br/>")
}

> look at lamp
A modern lamp. The lamp is on.


Thanks all, I've never seen that 'Print a message(no line break), yet there it is.
Mentally bangs fist against head. DOH!


K.V.

Thanks all, I've never seen that 'Print a message(no line break), yet there it is.

I just found that one a few weeks ago, although I scrolled right past it for months...

What had happened was:

XanMag used this line of code: PrintCentered ("KV [expletive deleted] [expletive deleted] and [expletive deleted].")

...and I was all like, 'how'd that jive turkey do that?'

So then, I just went old school:

msg ("<center>XanMag can [expletive deleted] a [expletive deleted], then [expletive deleted] that [expletive deleted].  Then [expletive deleted] THAT [expletive deleted], and [expletive deleted] [expletive deleted] [expletive deleted] [expletive deleted].</center>")

Digressions aside, I found the 'no line break' thing when I found the 'centered message' thing.

So...

Thanks, XanMag!


Oh. I was confused. (Why was it not on the same line anyway? ...)


K.V.

I didn't even see HK's post!

x = "A modern lamp.  The lamp is "
y = "on."
z = "off."
if (game.pov.parent.dark) {
  x = x + y
}
else {
  x = x + z
}
msg (x)

That does the same thing, too.


jmne,

I think he was doing this, but not appreciating the line break's existence:

msg ("A modern &#127875;.")
if (game.pov.parent.dark) {
  msg ("  The &#127875; is on.")
}
else {
  msg ("  The &#127875; is off.")
}

A modern 🎃. The 🎃 is on.


This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums