Photosensitive Lamp

Doctor Agon
30 Sept 2017, 21:48This 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.
The Pixie
30 Sept 2017, 22:11Try:
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.

Doctor Agon
30 Sept 2017, 23:01I'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.
mrangel
30 Sept 2017, 23:13If 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.

Doctor Agon
01 Oct 2017, 00:07Yeah @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.
jmnevil54
01 Oct 2017, 00:11Normally, the enter button.
This is a more serious example.
msg ("Hi.<br/>My<br/>Name is<br/>JMNE.")
hegemonkhan
01 Oct 2017, 05:35concatenation (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.
01 Oct 2017, 05:36There 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.
01 Oct 2017, 05:40Is there a way I can have the message printed on the same line
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.
01 Oct 2017, 05:42Or...
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.

Doctor Agon
01 Oct 2017, 06:50Thanks all, I've never seen that 'Print a message(no line break), yet there it is.
Mentally bangs fist against head. DOH!

K.V.
01 Oct 2017, 07:06Thanks 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!
jmnevil54
01 Oct 2017, 11:53Oh. I was confused. (Why was it not on the same line anyway? ...)

K.V.
01 Oct 2017, 12:26I 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 🎃.")
if (game.pov.parent.dark) {
msg (" The 🎃 is on.")
}
else {
msg (" The 🎃 is off.")
}
A modern 🎃. The 🎃 is on.