Solved

Visual Studio 2008 Generating Custom Code Off Of a User Interface from User Input

Posted on 2009-03-30
7
254 Views
Last Modified: 2013-11-26
Hello,  I am trying to figure out how to generate code from user input. In Visual Studio 2008, Visual Basic
I am new to this so I will try to explain the best I can. Thank you.
My script always begins with:

function Init(Quest)

Then from here a user would input a quest name, type and zone in a interface.

Ex:
RegisterQuest(Quest, "Kill Zombies", "Heritage", "Firestorm")
end

This part a user would enter in his interface what would an NPC say if accepted.

Ex:
function Accepted(Quest, QuestGiver, Player)
      if QuestGiver ~= nil then
            if GetDistance(Player, QuestGiver) < 30 then
                  FaceTarget(QuestGiver, Player)
                  Say(QuestGiver, "Thank you for accepting this task " .. GetName(Player) .. ".  Please return to me when you have completed it.")
                  Emote(QuestGiver, " thanks you warmly.", Player)
            end
      end
end

If the quest is denied

Ex:
function Declined(Quest, QuestGiver, Player)
      if QuestGiver ~= nil then
            if GetDistance(Player, QuestGiver) < 30 then
                  FaceTarget(QuestGiver, Player)
                  Say(QuestGiver, "If you change your mind " .. GetName(Player) .. ", you know where to find me.")
                  Emote(QuestGiver, " glares at you.", Player)
            end
      end
end

Last if the quest is completed

Ex:
function KilledAllCrabs(Quest, QuestGiver, Player)
      UpdateQuestStepDescription(Quest, 1, "I killed the zombies as Daniel requested.")
      UpdateQuestDescription(Quest, "I killed some of the zombies in the tomb.  Return to Daniel for your reward.")
end

What I need is a few text boxs that a user can input "Kill Zombies" or whatever they like and when they push a generate button it will create a file with a .quest extension.
All of the code remains the same except for the quotes that would be the user input from the interface.

Basically everything in quotes can be changed by the user in an interface.
I have created my own functions for when a user accepts, denys and completes a quest.
The user just needs to input what should happen then click a generate button to throw it all together as a .quest file to be saved in his or her quest folder for the server to call on later.

I also have many other functions like:
AddQuestRewardFaction --- (Quest, Faction ID, Amount)
AddQuestRewardCoin --- (Quest, Copper, Silver, Gold, Plat)
AddQuestStepObtainItem --- (Quest, Step ID, Description, Quantity, Percentage, TaskGroupText, Item ID(s))
Etc
Etc
I would also like to have these available on the UI but wont generate unless a user checks a box to add them or there is a box already for them but wont step into the code unless the user enters something into the box.

Is there anyone that can explain how I would go about doing this. Or maybe some kind of visual studio plugin that will help me out.  

Thank you again for taking the time to read.  I hope I explained my substitution well enough.
0
Comment
Question by:Daniel112
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24027434
Are you asking for a way to add dynamic TextBox controls to a form, and place them relative to other controls?
0
 

Author Comment

by:Daniel112
ID: 24033653
What im asking is how do I add a txtbox to a windows form to only edit what is in the "quoted" text of my script while keeping the code untouched.
This way when a user generates a .quest file it will have only edited the quoted text while keeping the script template intact.


0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24034815
How is the script executed?  It sounds like you might want to use variables, instead of hard-coded strings...

0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 

Author Comment

by:Daniel112
ID: 24035926
The script is LUA as far as how it is excuted I dont know.  I dont do server side stuff.  Im just trying to create a program for my team to create quests without having to copy and paste the same script over and over and only edit the whats in the quotes.

I am wanting to create a form that, when filled out, and when a button is pushed, will write a file out to disk for you.

If its more helpful I think I will be using
String.Format
File.WriteAllText

0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 24038706
That was what I was thinking--I meant macro expandable text before, not variables...
0
 

Author Comment

by:Daniel112
ID: 24045227
So would something like this work?

Dim s As String = "function Init(Quest)" & Environment.NewLine

Then based on the users values:
s &= "RegisterQuest(Quest, " & txtQuest.Text & ", " & txtType.Text & ", " & txtZone.Text & ")" & Environment.NewLine
s &= "end" & Environment.NewLine
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 24048506
Hmmm...I heard String.Format...but, that will work...

0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question