Script/Object misbehaving

RJSRdg
19 Oct 2020, 10:03

I've got the following lines of turn script at a specific location which are doing my head in:

if (ListContains(ScopeReachable(), large piece of cheddar cheese)) {
msg ("Cheese here")
MoveObject (moon high over the English Channel, Promenade 5)

When I take the cheese to the given location, I get the "Cheese here" message, so the 'if' statement is working correctly.
However the moon doesn't appear.

I've checked the object and it's set as a visible, non-scenery object. If I cut and paste the moon into the given location, I can see it, but if I leave it in its normal location the script doesn't bring it out.

The annoying thing is I've had this working before, and I can't think of anything I've done that would have stopped it.

Any suggestions?


mrangel
19 Oct 2020, 10:41

Once it should have brought the moon out, is the moon reachable?

Try doing something like "look at moon". If it gives an error, it must have failed to move the object for some reason. Possibly you could add a line printing out the properties of the moon. If it shows the description, it could be that the moon is actually there, but the places/objects pane has failed to update for some reason.

Two different problems, so it would be good to know which one we need to deal with.


R2T1
19 Oct 2020, 11:06

It looks like you have left off the closing brace '}' after Promenade 5)


RJSRdg
19 Oct 2020, 13:19

mrangel - not quite sure what you mean by "reachable" but if I type "Look at moon" it comes back with "I can't see that"

R2T1 - there are other things which happen in the "if" statement after moving the moon, I just copied the relevant part of the code, hence the missing bracket.


mrangel
19 Oct 2020, 15:47

I assume Promenade 5 is the current room, and it isn't dark? Is the script in the same room, ot do you have to go to the room with the script and then go to Promenade 5?
Is there any other script that could be moving the moon?

Might be worth checking all the attributes, see if everything is set to what it's supposed to be.
Something like:

foreach (attr, GetAttributeNames (moon high over the English Channel, true)) {
  if (not HasScript (moon high over the English Channel, attr)) msg (attr + ": " + GetAttribute (moon high over the English Channel, attr))
}

after it should have been moved, and see if there's any attributes that aren't what you expect them to be.


Forgewright
19 Oct 2020, 16:51

The debugger during gameplay is a great way to check attributes


RJSRdg
19 Oct 2020, 16:54

"Promenade 5" is a neighbouring room - I've now modified the script to move the moon to the room the script runs in "Novelty Rock Emporium" in case anything odd's been happening when I leave the room.

Now, when I move the cheese to the room, I get....

Cheese here
name: moon high over the English Channel
elementtype: object
type: object
parent: Object: Novelty Rock Emporium
alt: List: moon;
hasbeenmoved: True
visible: True
displayverbs: List: Look at; Take;
inventoryverbs: List: Look at; Use; Drop;
take: False
use: False
givesingle: False
drop: True
gender: it
article: it
possessive: its
wornmodifier: worn
isopen: False
open: False
close: False
container: False
descprefix: You are in
objectslistprefix: You can see
exitslistprefix: You can go
contentsprefix: containing
description:
implementation_notes:
scenery: False
hidechildren: False
listchildren: False
usedefaultprefix: True
volume: 0
price: 0
dark: False
lightstrength:
darklevel: False
grid_width: 1
grid_length: 1
grid_fill: White
grid_border: Black
grid_borderwidth: 1
grid_bordersides: 15
grid_render: False
grid_label:
grid_label_colour: Black
grid_parent_offset_auto: True
grid_parent_offset_x: 0
grid_parent_offset_y: 0
pov_alias: me
pov_alt: List: me; myself; self;
pov_look: Looking good.
pov_gender: you
pov_article: yourself
pov_possessive: your
feature_usegive: False
feature_container: False
feature_switchable: False
feature_edible: False
feature_player: False
feature_lightdark: False
visited: False
timesexamined: 0
not_all: False

All look to be what I'd expect, but it still doesn't appear :-(


mrangel
19 Oct 2020, 17:13

That seems like it should be working. I can't think what could be causing a problem there.

Do you have a shareable link to the game? I could take a look through it and see if anything jumps out at me.


The debugger during gameplay is a great way to check attributes

I would have recommended that, but I've seen someone with an issue before where the debugger sometimes showed old values for some reason.


RJSRdg
19 Oct 2020, 17:44

No, sorry - all been developed on my laptop so there isn't (currently) an online version. I was in the process of making some (final?) checks when I noticed this wasn't working.


RJSRdg
20 Oct 2020, 20:58

Solved it now, anyway - it was an error in the remaining (supposedly irrelevant) part of the script that was moving it back again!