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

Adds new examine actions: notify and transform. #716

Merged

Conversation

Kaylakaze
Copy link
Contributor

@Kaylakaze Kaylakaze commented Jul 26, 2021

Summary

SUMMARY: [Mods] "Adds new examine actions: notify and transform"

Purpose of change

This is to provide modders with more functionality. A lot can be accomplished with just the ability to transform an in-world object and the notify action is just to allow the modder to provide feedback to the user.
Fixes #711

Describe the solution

Two new examine-actions are available to modders: notify and transform.

  • Notify: When the object is examined, a popup will be shown with the contents of the object's message property.

  • Transform: When the object is examined, it changes into the object specified by its transforms_into property. If the new object has a message property, it is displayed in a popup, like the notify action.

Testing

I created a mod that used each examine action and verified that it worked as expected. As the code is very basic and only adds to the existing code instead of

notify and transform.

- Notify: When object is examined, a popup will be shown
with the contents of the object's message property.

- Transform: When object is examined, it changes into the
object specified by its transforms_into property. If the new
object has a message property, it is displayed in a popup.
@chaosvolt
Copy link
Member

Haven't thought of a vanilla use for notify aside from as a quick way to grok description for stuff that doesn't already have an examine action, but some potential vanilla uses for transform:

  1. If it can be set to optionally spawn items on transform, I'd be able to replace the hacky-looking "flag on the ground next to a column" flag spawns with flagpoles as an explicit furniture, with said pole having the player take the flag down as a one-way transformation.
  2. If the right active function for powered lights is written then that'd combine with this to make grid-powered lights the player can turn on or off a thing. If I'm looking at how this works correctly, it SHOULD hopefully be able to rig it such that a power-consuming active function will only perform its function when power is available, so there wouldn't even be a need to hack in any sorta auto-transforming stuff. It'd just have the active lamp give off light if there's power, and not give off light if power's out (as lamps don't automatically turn themselves off when out of power anyway).

I could see if I can make idea two a thing, that might compliment this addition...

@chaosvolt
Copy link
Member

Smol side note, the JSON example provided in the OP lacks a transform message, it seems?

@Kaylakaze
Copy link
Contributor Author

Smol side note, the JSON example provided in the OP lacks a transform message, it seems?

That is correct. I did test it with one, but in the final, I just wanted a lamp that turned on and off.

@chaosvolt
Copy link
Member

What's the default message if one is absent?

@Kaylakaze
Copy link
Contributor Author

For transform, if there isn't one, the popup never triggers. For notify, if there's no message, you get a tiny empty popup box.

@Coolthulhu
Copy link
Member

That is correct. I did test it with one, but in the final, I just wanted a lamp that turned on and off.

Could you add it to a file? For example, a new file data/json/furniture_and_terrain/furniture-testing.json.
Having a testable example in the repo is pretty vital. Without it, someone may remove the functionality, because it looks unused.

@Coolthulhu
Copy link
Member

Astyle check is failing because you have used different spacing in ifs and newlines around else.
I'm not sure what IDE are you using, but if it's one of the popular ones, it should have support for astylerc. Alternatively, manually setting it to put spaces in ifs like if( x ) and to keep } else { as one line could be enough.

@Coolthulhu Coolthulhu self-assigned this Jul 31, 2021
@Kaylakaze
Copy link
Contributor Author

I have officially reached "Fuck it"

@Coolthulhu
Copy link
Member

I have officially reached "Fuck it"

It's just a json error. Run it through https://dev.narc.ro/cataclysm/format.html and it should work.

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

Successfully merging this pull request may close these issues.

[Request] A couple of new "examine_action"s
3 participants