In the game, I have a character that you communicate with by typing numbers on a calculator – like 07734 and then turning it upside down to say 'hELL0". The images for the numbers show digital calculator entries and are titled:
figure of image 01134 is the file "01134.jpg".
figure of image hello is the file "hello.jpg".
The files are named the same as in the folder.
The language for turning the calculator upside down (or rightside up) is:
rotating is an action applying to one thing. understand "Rotate [something]" as rotating.
instead of rotating calculator:
if calculator is updown:
now calculator is rightup;
say "You turn the calculator 180 degrees so that it is rightside up.";
stop the action;
if calculator is rightup:
now calculator is updown;
say "You turn the calculator 180 degrees so that it is upside down.";
The definition of the calculator is:
calculator is a thing. it is in Jewelry_Store. "Sitting by itself on a counter is a solar calculator.". The description is "It's a solar calculator with big buttons, the standard 10-key format with merely plus, minus, multiplication, and division and a clear button. It has a large display.". calculator is readable. calculator can be rightup or updown. calculator is rightup.
The problem is that the right digital file will load only when the calculator is right up. Here’s the language of the expression:
instead of examining calculator:
say "It's a solar calculator with big buttons, the standard 10-key format with merely plus, minus, multiplication, and division and a clear button. Is has a large display.[If calculator is updown]The calculator is updside down.[paragraph break]The display screen reads:[line break]";
if calcvalue is 01134:
if calculator is rightup:
display the figure of image 01134;
if calculator is updown:
display the figure of image hello;
I have been trying for hours to figure it out, just opening it up here to more experienced eyes. Does the image need to be cleared once it is displayed?
Have you defined the command “rotate” as something new? By default, Inform understands “rotate” as a synonym for the built-in turning action, so typing ROTATE CALCULATOR wouldn’t actually reach your new instead rule and just get blocked by one of the generic “can’t turn” rules.
If that’s not it, don’t really have any other ideas unfortunately – images are beyond my comfort level with Inform!
calcvalue is a number that varies. calcvalue is 0.
I know that the calcvalue is entering correctly. If I input 1337 the character responds to this, even though I don’t get an updside down image. I get a rightside up one, though.
Displaying images is something that should just work with if statements. I do this kind of thing a lot in my WIP.
Like Mike suggests, I would bet that the existence of rotating is leading to undesirable behavior.
Have you tried leaving rotating out and just using
instead of turning calculator ? (I ask because your declaration does not make it something new)
Have you tried the logic with regular text to confirm it is an image problem?
working image stuff:
This is the display kitchen image rule:
if resolution is 1:
display figure of kitchen 480;
otherwise if resolution is 2:
display figure of kitchen 720;
otherwise if resolution is 3:
display figure of kitchen 1080;
otherwise if resolution is 4:
say "Image description: [KitchenText]";
What I would do to try to track this down is to replace the “display the image” parts of your code with say statements and see what happens. As in:
instead of examining calculator:
say "It's a solar calculator with big buttons, the standard 10-key format with merely plus, minus, multiplication, and division and a clear button. Is has a large display.[If calculator is updown]The calculator is updside down.[paragraph break]The display screen reads:[line break]";
if calcvalue is 01134:
if calculator is rightup:
say "01134.";
if calculator is updown:
say "hello.";
No, unfortunately I had to do that myself. Support for images is a bit different from interpreter to interpreter, so I decided just to compile with multiple resolutions. It was the only way I could guarantee (or come close, anyway) a good image viewing experience for a wide range of screens in Inform 10. In my game, resolution is a variable that the player selects at the beginning of the game via a keypress.
Purpose of the sample was just to model some straightforward “if” statements that work reliably.
Without taking specific action, you are probably getting default behavior for turning things, which is nothing. This is what Mike was getting at.
Instead of defining Rotating in any way (comment out all of that), I’d try going straight to this. Rotating is already built into Inform.
instead of turning calculator:
if calculator is updown:
now calculator is rightup;
say "You turn the calculator 180 degrees so that it is rightside up.";
stop the action;
if calculator is rightup:
now calculator is updown;
say "You turn the calculator 180 degrees so that it is upside down.";
That should incorporate rotating, which is a built-in synonym for turning.
Yeah, this is the approach I’d recommend – sorry, I should have been clearer, if you write the statement “understand the command “rotate” as something new”, that will break it’s previous associations. But as Drew says, I’d stick with the built-in action and test whether the logic works before moving on to seeing if it’s an image problem.
While I agree that should be tried, Matt says he tried my suggestion to just use say statements instead of displaying anything to check the logic and it seemed to work ok.
@mattdevins What 'terp are you using to test this? One of the ones built-in to the IDE? (I don’t even know if that’s possible/recommended; I don’t think I’ve ever worked with images.) Are you compiling for release and then testing in a separate interpreter or compiling to a web page and testing in Parchment or whatever?
I just substituted “turning” for and defining “spinning” to spin the calculator 180 degrees. Still prints the same image whether upside down or rightside up.
this doesn’t address other issues, but if you have a whole bunch of these, you might find it useful to adopt a scheme sort of like this:
Figure of f-01134 is the file "01134.png".
Figure of hello is the file "hello.png".
Figure of zero is the file "zero.png".
A calculator-readout is a kind of object.
Some calculator-readouts are defined by the Table of Readouts.
Table of Readouts
calculator-readout right-side-up image (figure name) right-side-up text upside-down image (figure name) upside-down text
zero-0 figure of zero "0" figure of zero "0"
hello-01134 figure of hello "hell0" figure of f-01134 "01134"
To say the/-- calculator's display screen:
say "The display screen reads: [if the calculator is upside-down][upside-down text of the current display of the calculator][else][right-side-up text of the current di\
splay of the calculator][end if].";
display the calculator image;
The calculator is a thing with description "It[']s a solar calculator with big buttons, the standard 10-key format with merely plus, minus, multiplication, and divisio\
n and a clear button. It has a large display. [if the calculator is upside-down]The calculator is currently upside down.[end if][paragraph break][calculator's display\
screen]";
The calculator can be upside-down or right-side-up.
The calculator has a calculator-readout called the current display.
The current display of the calculator is zero-0.
To display the calculator image:
if the calculator is upside-down, display the upside-down image of the current display of the calculator;
else display the right-side-up image of the current display of the calculator;
rather than have different to-phrases for different figures.
That’s the frustrating part, there’s only three ‘words’ that I want to be able to be turned upside down. Thank you for the template, I will take a look at it, see if it helps.
Matt, I just copy-pasted your code from above into a project, the only things I changed were that I used .png files instead of .jpg (because I had those lying around), and let calcvalue be changed by a jumping action, for quick testing; and left out reading.
This works for me, that is, it shows different pictures:
figure of image 01134 is the file "01134.png".
figure of image hello is the file "hello.png".
Jewelry_Store is a room.
calculator is a thing. it is in Jewelry_Store. "Sitting by itself on a counter is a solar calculator.". The description is "It's a solar calculator with big buttons, the standard 10-key format with merely plus, minus, multiplication, and division and a clear button. It has a large display.".
calculator can be rightup or updown. calculator is rightup.
calcvalue is a number that varies. calcvalue is 0.
rotating is an action applying to one thing. understand "Rotate [something]" as rotating.
instead of rotating calculator:
if calculator is updown:
now calculator is rightup;
say "You turn the calculator 180 degrees so that it is rightside up.";
stop the action;
if calculator is rightup:
now calculator is updown;
say "You turn the calculator 180 degrees so that it is upside down.";
instead of turning calculator:
try rotating calculator.
instead of examining calculator:
say "It's a solar calculator with big buttons, the standard 10-key format with merely plus, minus, multiplication, and division and a clear button. Is has a large display.[If calculator is updown]The calculator is updside down.[paragraph break]The display screen reads:[line break]";
if calcvalue is 01134:
if calculator is rightup:
display the figure of image 01134;
if calculator is updown:
display the figure of image hello;
Instead of jumping:
now calcvalue is 01134.
Just to be 100% sure, have you double-checked that the actual image files in the correct directory show different things? When trying out various things, it can easily happen to copy something over by accident.