1 year ago

I just found out Godot doesn't seem to have any native way to display windows message boxes.

It DOES have one for alerts (the ones that only give "ok" as an option).

but I want multiple-choice, so I had to use powershell, I'll explain in Article :3


Tbh this is something I've had problems with for a WHILE now. It's really annoying that there's no native way for this :(

Well first we'll have to write an empty "output" array for the OS.execute() to fill

		
			var output = []
		
	

after which, we have to execute the powershell script to display said MessageBox

		
			OS.execute("powershell.exe", ["-Command", "Add-Type -AssemblyName PresentationFramework;[System.Windows.MessageBox]::Show('Body', 'Title', '3','16')"], output)
		
	

let me explain with the little knowledge I have of powershell...

"-Command" opens powershell with the intent to execute code.

"Add-Type -AssemblyName PresentationFramework;[System.Windows.MessageBox] creates everything that's needed to actually use the messagebox.

::show is the messagebox's argument to actually show itself...

and for the arguments within show, I recommend looking at THIS <- Click Webpage, It explains everything pretty well :D

after it has been opened, we need to actually check what the user has clicked, which is where the afformentioned "output" variable comes in.

if we check output by printing it after

		
			print(output)
		
	

we can see that output[0] contains either Yes\r\n, No\r\n, or Cancel\r\n

the \r and \n are escape characters, don't worry about it, that shouldn't change anyway.

\r is Carriage return and \n is Newline.

anyway, after that we can match output[0] like so:

		
			match output[0]:
	"Yes\r\n":
		print("The user has ACCEPTED the Prompt")
	"No\r\n":
		print("The user has DECLINED the Prompt")
	"Cancel\r\n":
		print("The user has CANCELED the Prompt")
		
	

and there's your itty bitty textbox :3



5 comments

Loading...

Next up

The combat system is already being implemented and there are also some advances with the environment (WIP)

#gamedev #indiedev #godot

Weโ€™re excited to announce that weโ€™re working on a new game, a 3D metroidvania with a Low Poly Pixel Art style. Stay tuned for more updates!!!

#gamedev #indiedev #pixelart

It's Halloween! let's talk about SCARE.

Short intro of us ๐Ÿ’•โœŒ๏ธ

We're an eletro duo based in Seoul ๐Ÿ‡ฐ๐Ÿ‡ท Heavily influenced by the 90s.

Our new album #Xennials is all about the nostalgia of that era ๐Ÿ’ฝ CD listenin ๐Ÿ“Ÿ beeper beepin ๐Ÿ’พ floppy disks floppin days ๐Ÿ˜Ž

Stream now! ๐ŸŽง

https://open.spotify.com/album/3YwWhnHWVy5cA8XOpbaGRA?si=8E9awqUโ€ฆ

"Thanks guys for endless hours of fun." ๐Ÿ‘

(My first fan art. Read the article, please.)

#sonic #mario #photoshop

๐Ÿ’Did you like the game? A demo is available for free on Steam.

โœŒ๏ธ Thanks for playing IndieGameiacs!

โš™๏ธ Free Demo: http://bit.ly/UniDuni

๐Ÿ“บ Full Video: https://youtu.be/5qEbVXg7GaQ

#steam #uniduni #clops #screenshotsaturday

Today I was setting up the location of the first boss. His name is "Father" and he is the first of the Patagonians. His task is to guard the road to the House.๐Ÿ›ก๐Ÿ—ก Bookmark pre-launch page๐Ÿ”–๐Ÿ”–๐Ÿ”–

https://www.kickstarter.com/projects/rdvindiegame/the-patagonianโ€ฆ

I was bored, so... ManutKat.

A house I've built a while ago. :)

It nicely separates the snowy biome from the grassy one.

It's built with painted Ebonstone.

Spaaaace~

These are background sprites I've created for a game I'm working on at school ^w^ Click on the post to see how the sprites connect. You won't regret it! (personally, I think it's pretty heheh)

Drawn in Piskel using my mouse. Whaddya think?