Exemple #1
0
func specificNpcMenu(s *Session, npc types.NPC) {
	utils.ExecMenu(npc.GetName(), s, func(menu *utils.Menu) {
		menu.AddAction("r", "Rename", func() bool {
			name := getNpcName(s)
			if name != "" {
				npc.SetName(name)
			}
			return true
		})

		menu.AddAction("d", "Delete", func() bool {
			model.DeleteCharacter(npc.GetId())
			return false
		})

		menu.AddAction("c", "Conversation", func() bool {
			conversation := npc.GetConversation()

			if conversation == "" {
				conversation = "<empty>"
			}

			s.WriteLine("Conversation: %s", conversation)
			newConversation := s.getRawUserInput("New conversation text: ")

			if newConversation != "" {
				npc.SetConversation(newConversation)
			}
			return true
		})

		roamingState := "Off"
		if npc.GetRoaming() {
			roamingState = "On"
		}

		menu.AddAction("o", fmt.Sprintf("Roaming - %s", roamingState), func() bool {
			npc.SetRoaming(!npc.GetRoaming())
			return true
		})
	})
}