Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New-line character in room title crashes status bar #59

Closed
crabcode opened this issue Jun 16, 2023 · 6 comments
Closed

New-line character in room title crashes status bar #59

crabcode opened this issue Jun 16, 2023 · 6 comments

Comments

@crabcode
Copy link

This may be an issue of bad practice (I'm very new to this), but I've tried formatting my output by doing the following:

Object Forest "^  FOREST"
    with ...

This does work the way I want it to in WinFrotz, but when running it in a C64 emulator, it seems to get stuck after printing the title, description and ">". The status bar isn't drawn and input doesn't work anymore. There's no error or anything, it's just frozen.

Removing the "^" makes it work again and I was able to have my line break by putting it into the short_name instead, but perhaps the status bar could somehow ignore the character to prevent crashing?

@johanberntsson
Copy link
Owner

I would say that this is simply bad practice, and that it would be better to rewrite your code. What you define is the short_name property of the object, and if you check the Designer's Manual (DM4) you will find no example of short_name that is anything other than a single word or short phrase, suitable to write on a single line. There is a good reason for this; z3 games cannot customize their status line, and always drawn with on one line. Adding newlines would create problems. If you make a z5 game you have the option of supplying your own status line routine, and can customize the status line to be multiple lines.

It would be possible to add the filtering you suggest, but the goal of Ozmoo is to be as small and efficient as possible in order to run on very resource-restricted 8-bit platforms, and adding code for avoiding what is arguably a programming mistake is not worth it, IMO. Because of this, I suggest simply avoid adding newlines in short_name and instead modifying other parts of your game to get the desired effect. If you have further questions you can go to the support or programming -tips sections on the punyinform discord server.

@crabcode
Copy link
Author

Makes sense. To be clear, I didn't want to customize the status bar, just have the paragraphs separated by an extra line in the "body" of the output, and defining it in the short_name property (i.e. Object Forest "FOREST" with short_name "^ FOREST") works without breaking anything, then the status bar prints the first name and uses the short_name in the body.

I'm also noticing that I what I thought was a difference in size when I add the short_name property to all my rooms was just the difference in reduction by the compression, which results in the exact same file size, so not a problem on that end either.

Thanks!

@fredrikr
Copy link
Collaborator

fredrikr commented Jun 23, 2023

@crabcode: If you're using PunyInform, to get the desired effect, just add this to your source before including puny.h:

Constant MSG_LOOK_BEFORE_ROOMNAME = "";

@crabcode
Copy link
Author

@fredrikr Ooh, thanks! I did eventually find the customization with LibraryMessages, but that's even simpler! :) Clearly lots to learn still.

@fredrikr
Copy link
Collaborator

Oh, sorry, the metod I pointed out isn't reliable. You need to declare it as a numeric constant and write code for it in your LibraryMessages routine!

Explanation: The library message system supports two kinds of messages - simple (strings) and complex (code). If a message is of the complex type in messages.h, you can't replace it with a simple message in your game. This is due to a technical limitation with the compiler. Replacing a simple message with a complex one is supported.

@crabcode
Copy link
Author

@fredrikr Ah ok, gotcha. It did work when I tried it out, but I'm using WinFrotz for quick testing and am starting to realize it might be a bit too forgiving, letting me get away with some pretty bad code at times that then confuses me when it doesn't translate to other systems. So that's helpful to know, thanks for clarifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants