Skip to content

A lightweight and intuitive form builder for Dragonfly-MC servers, making it easy to create and manage button-based menus.

License

Notifications You must be signed in to change notification settings

RedStoneCraftGG/simpleform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simpleform

A lightweight and intuitive form builder for Dragonfly-MC servers, making it easy to create and manage button-based menus.

Usage

Normal Form

func TestForm(p *player.Player) {
	simpleform.New("title", "desc").
		B("text1", "", func(p *player.Player) { p.Message("Clicked!") }).
		B("text2", "", func(p *player.Player) { p.Message("Clicked!") }).
		B("text3", "textures/red/carlotta", func(p *player.Player) { p.Message("Clicked!") }).
		Close(func(p *player.Player) { /*optional*/ }).
		S(p)
}
image

Submit Form

func TestSubmit(p *player.Player) {
	simpleform.NewSubmitForm("Settings", "Description (Currently doesn't showed up)").

		// text: string, options: []string, default(optional): int
		Dropdown("Your favorite color:", []string{"Yellow", "Red", "Blue", "Green"}).

		// text: string, default(optional): bool
		Toggle("Turn on night mode?").

		// text: string, min: int, max: int, step: int, default(optional): int
		Slider("Volume:", 0, 100, 5).

		// text: string, placeholder: string, default(optional): string
		Input("Type your Nickname:", "Nickname").
		OnSubmit(func(p *player.Player, r simpleform.SubmitFormResponse) {
			color := r.Dropdown(0)   // index 0
			nightMode := r.Toggle(1) // index 1
			volume := r.Slider(2)    // index 2
			nickname := r.Input(3)   // index 3
			p.Messagef("color: %s, Night Mode: %t, Volume: %v, Nick: %s", color, nightMode, volume, nickname)
		}).
		OnClose(func(p *player.Player) { /*optional*/ }).
		S(p)
}
image

Modal Form

func TestModal(p *player.Player) {
	simpleform.NewModalForm("Conrim", "Do you want to have 271T added to your account?").
		B1("YESSSS PLEASE!!!", func(p *player.Player) { p.Message("271T was added to your account") }).
		B2("(Calmly Reject)", func(p *player.Player) { p.Message("You reject the offer") }).
		S(p)
}
image

About

A lightweight and intuitive form builder for Dragonfly-MC servers, making it easy to create and manage button-based menus.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages