Skip to content

Add randi, randf, randf_range and randi_range blocks #193

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

Closed
wants to merge 4 commits into from

Conversation

jfcharron
Copy link
Contributor

This PR allows users to use these 4 godot global functions (randi, randf, randf_range and rangi_range) to generate random numbers as requested in #185.

b = BLOCKS["parameter_block"].instantiate()
b.block_name = "randf_range"
b.variant_type = TYPE_FLOAT
b.block_format = "randf_range({from: FLOAT}, {to: FLOAT})"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block_format goes to the UI label so you can be verbose: Get random float from {from: FLOAT} to {to: FLOAT}. And you can also add tooltip text with the explanation in Godot docs:

b.tooltip_text = "Returns a pseudo-random float between [i]from[/i] and [i]to[/i] (inclusive)."

The tooltip text supports rich text with BBCode format.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do, thank you for your suggestion

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to you for contributing this!

jfcharron and others added 3 commits August 13, 2024 23:36
According to the discussion [1], add the sound blocks into function
get_built_in_blocks()'s class matching. It generates blocks belonging to
AudioStreamPlayer node, including setting the property's value.

Therfore, we have sound blocks in both types of general script and
GDScript flavor.

[1]: endlessm#161 (comment)

https://phabricator.endlessm.com/T35609
@jfcharron jfcharron closed this Aug 14, 2024
@jfcharron jfcharron deleted the random branch August 14, 2024 03:51
@jfcharron
Copy link
Contributor Author

Sorry, about creating a new pull request (#194). I am new to this github workflow.

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.

3 participants