Declaration of variables with unknown names - air

I'm current working on a game engine in which players have an option to create their own world to play and share with others. The engine itself is driven by text files. It is also getting developed in adobe AIR.
I'm wanting players to have the ability to create their own variables to use for the world's they make. The only types they would are int and string variables.
Since I cannot find any resource that will let me dynamically name variables, I was wondering if there is any clever way I could make it act like they are dynamically named. The players will need to be able to give it a name to refer to it and of course contents that they want it to hold.
Any help on this would be most appreciated.

Since they are using text files, I assume you are parsing and processing these text files. If that's the case, store the variables in a map as the user defines them. You could use two maps, one for ints, one for Strings, or a single map that has both. The key would be the variable name, which maps to its current value.

Related

CATIA Script to Rename All Objects in Specification Tree

I am looking for a CATIA script to replace the names of all objects in the specification tree of a CATPart with a constant string suffixed by a running number. As an example, consider the following specification tree before renaming (left picture) and after the script run (right picture):
Background is the removal of sensitive information (such as part numbers of electronics components) for preparation of a STEP export of a large assembly.
Well this certainly is not a hard one to write and figure out. As I understand StackOwerflow is not a site where you get a code on demand but a site where you get help with your code.
I will give you a hint. What you are looking for are collections of objects which holds features, bodys, constrains etc. and iterate trough all these collections and change the names.
I would start recording macro when you manually change the names, then take a look at the script and learn from it.

How to store an equation and/or random number generator inside of a SQL database?

I'm still in college and I'm trying my hand at designing my own applications, for practice and also for funsies, but I'm having some big questions.
Currently, I'm attempting to design an application that uses a relational database backend to store records related to a pen-and-paper RPG that a friend and I have been designing. It will need to store characters, weapons, items, etc. Since it's based off of a sci-fi universe, there are guns, etc.
Now, I'm stuck in the conceptual stages here because I'm not sure how I would store some of the weirder to grasp types of information here. Since it's a tabletop RPG, there are dice involved, typically referred to as D4, D6, D10, D20, etc. and a lot of these weapons, for example, have several kinds of attacks each (they're guns, so it's like firing modes, etc.) and a typical attack would be something like "D20 + 20."
Now, I know that I could just store it as a string variable, but I was hoping to design this in such a way that I could actually add some dice-rolling/etc. functionality to it. Is there a simple or effective way of storing a Math.random variable (not the result, mind you, but the actual range number) in a SQL record so that I could just grab it and use it real quick?
For extra context, I was hoping to have one table of the actual weapon templates & stats and another table of just actual instances of those weapons, so I could keep track of ammo in each gun, who owns it, etc.
I'm using Netbeans and a Derby database. Thanks for any help you guys.
As stated above, I don't know why you just wouldn't create a java/C#/any programming language application that can simulate the dice rolls for you. I mean, you could integrate the database into the application to retrieve information. Otherwise just simply make the ability to input information on weapons/Armour into the application in the form of popup dialog boxes (Or something along those lines).
A database is primarily used to store information in a structured way and automatically updates this information as needed. What you are suggesting to do is more dynamic and has nothing to do with storing information and more so with actually playing the game. Not wanting to change your idea about creating it. Just creating an actual application that utilizes a database can be written in a language other than SQL. (And much easier to do it this way as well.)
Your question is very broad, but I would not store a descriptive characteristic like "D20 + 20" in your database only yo parse it out in the app. Instead store that as two or three (depending on what it represents) attributes (columns) in your database, and let the app display it appropriately.
I don't know exactly what you mean by storing "equations" and "RNGs" in your database, but those belong in the application, not the database. You can store inputs or parameters that guide those equations, but not the equations themselves.

Efficient way to translate an application

So i have developed an application in vb.net but recently i came across the requisite of allowing multiple languages for it. I dont know if there is any 'common' way of doing this kind of things, but my approach to accomplish that is the following:
I'll need to search in the code for components, error messages and everything that is displayed in the GUI of the application to be translated.
Secondly i will create a class in which i'll store in memory a dictionary of everything that will be translated
after, i'll replace the stuff to be translated withing an entry of the dictionary
then when the application start i'll load the dictionary
later on, i'll replace the static dictionary and will load it in memory from the database
So for example, my dictionary class:
Dim dictionary As New Dictionary(Of String, String)
dictionary.Add("00011", "hello there!")
Somewhere in my code i'll replace:
mylabel.text = "hello there!"
With:
mylabel.text = dictionary.item("00011")
Later on i will, instead of having a static dictionary, create that dictionary getting the information from a database like this (and load it at the start of the application:
_______________________________________
word_code ### word_EN ### word_FR
_______________________________________
00011 ### hello there ### bonjour il
I will load the dictionary considering which language is selected.
I'm not very confortable with this approach and i have no idea if this is the right thing to do, but if so i have a couple of questions:
is a dictionary the best data-structure to do so?
will this be memory-heavy considering i'll have 1000 entries, 1m entries or 10m entries?
is there any logic and faster way of accomplish the same?
Thank you so much in advanced,
J
It's a common way of doing it - having a system name along side a language code being used to look up a translated value. However, generally speaking I'd only advice you to do this for something like system texts and smaller text segments.
The reason is that in for example CMS/ecommerce systems, pages with lots of text likely will need to be translated in a data model to support it to begin with; and then you already have the language division.
So in that situation, you're better off making a page structure with a translated data model where the detail will be language specific per language for your current website.
For example, you'll have a product -> product_detail where detail keeps the translated values for said product. Similar for article -> article_detail and so on.
But for general translations and system texts which needs to be displayed, it's a common way to do it.
And as you suggest yourself, structures like like dictionary would be a good structures to to make fast look ups and can be cached in the system so you do not need to retrieve them all the time.
Some ways you can expand on it, is by sub dividing your translations into sub groups; say you have an order page and a product page. Then you can have translations assigned to "product" and to "order" with a "common" group as well.
It will also make it easier to build smaller cache objects, extract less data from your data storage etc, so a page which only revolves around orders don't need to worry about product translations.
It will require memory, but unless you put entire CMS systems into the translations, it should be "minor".
I would however question a need of 10 million entities of translations and wonder whether or not your system actually requires that many and if it does, then maybe consider an alternate approach and whether it might be better to make multiple versions of the "page" to eliminate the need for translations.
I would also advice you to not use "00011" as a system code to begin, and go for a more "readable" version (like "hello") to ease the readability and maintainability of your code. Then if you want a 'system value' which is like "00011", it's easy to do a search/replace.

Building an Interface for User Generated Graphs

I've researched this issue and have not found anything to meet my needs. I am worried that perhaps I'm using the wrong terms.
I would like to build a website interface that allows users to select different variables and then have those variables dynamical or automatically graphed or charted. I need it to be able to handle 100+ variables (there could be limits to how many were charted at one time) and display the data on a bar graph, pie chart, or line graph based on the users preference.
What would I need to make this happen?
Sounds like you need to use either Flash and ActionScript or JavaScript and HTML5.
I've been looking to do something like this too actually.
Need a facility for parsing the data, and then working out scales/ratios and to represent the data in a coherent way, with labels. Then you need to scale the shapes your using according to the scale that the data is covering, and for the sizes to naturally be proportional.

Entity, Value Object or what is it and where it should be?

I have class called 'Tool'. Tool has properties like: Name, Description and some specific others. Tool is special because Name and others are read only but description can be modified by users.
Count of tools is constant and known at development time. It is not Value Object because I need to query them and show to users where they can update Description. So, it's kind of Entity but users can not create new Tools.
I'm looking for possibility to take Tool like this:
Tool.SomeGreatTool
where SomeGreatTool is Tool with name "Some great tool" and description should be the same like this specified by user.
Jimmy Bogard has solution almost perfect but NHibernate know anything about SomeGreatTool and Description will be null.
How to modify Jimmy's solution or how to do it different way? How to instantiate SomeGreatTool from database?
We still treat these kinds of semi-constant data as a sort of well-known entities. We create value objects/enumeration classes for the tool types, but separate tool types from tools. You still need to go to the persistent store to do something like ToolRepository.Find(ToolType.Screwdriver). Even though there will be only one tool per tool type, you'd still separate these two concepts.