m_switch

Member
  • Content count

    58
  • Joined

  • Last visited

Community Reputation

234 Neutral

About m_switch

  • Rank
    Member
  1. [quote name='deepdene' timestamp='1295220020' post='4759840'] [quote name='m_switch' timestamp='1295206621' post='4759746'] Note that the semantics of properties and public variables that return value types are different. For public variables, you are directly accessing the variable. However, a property that returns a value type makes a copy of the variable. [/quote] [font="arial, verdana, tahoma, sans-serif"][size="2"]In both instances with value types the values are placed onto the evaluation stack and popped into the appropriate stack variable. ...[/size][/font] Also the only difference between a automatic property and providing the backing field yourself in terms of MSIL is the fact that the compiler adds an attribute to the field I believe to indicate it's compiler generated. [/quote] This is an implementation detail, I was speaking in reference to the semantics. Visual Studio will actually generate an error when you attempt to modify a copy of a property's backing store (directly). See [url="http://msdn.microsoft.com/en-us/library/wydkhw2c%28v=vs.71%29.aspx"]http://msdn.microsof...v=vs.71%29.aspx[/url]
  2. [quote name='SiCrane' timestamp='1295205247' post='4759741'] [quote name='ApochPiQ' timestamp='1295203640' post='4759727'] Consider: in C#, the syntax foo.Field will work to access Field whether Field is a public member [i]or [/i]a property. So the best course of action is to begin with public fields, and [i]if[/i] you need to refactor to add logic later, drop in a property named Field with the associated logic. No calling code needs to be changed, meaning you only have minor code site updates to make, and everything continues to work swimmingly. [/quote] The syntax is the same, but the generated MSIL is different. This means that if you change from a public field to property, you can't do a drop in binary replacement. Calling code still needs to be recompiled. [/quote] Note that the semantics of properties and public variables that return value types are different. For public variables, you are directly accessing the variable. However, a property that returns a value type makes a copy of the variable.
  3. Games with good melee combat

    Seconding Dark Messiah of Might and Magic (PC, the 360 port was not very good). Easily the most immersive melee combat I've ever experienced.
  4. virtual machine memory storage type

    Why not have three (or however many) separate vectors/containers instead of trying to jam everything into one?
  5. Setting the alpha multiple times in the same frame won't have a visual effect. Only the value at the end of the frame will be used to draw the clip. Either keep state between frames to determine the alpha (loop is unnecessary) or use a tween library like Greensock designed to simplify what you're trying to do.
  6. lua_pcall hooking

    That's not always the case. Functions aren't named in Lua, but can used as a value in a table. Which is exactly how global functions work; _G is just a "special" Lua table used for globals. Consider the following: In Lua: SomeCFunction(function() print("what is my name?") end) In C: int SomeCFunction(lua_State* L) { lua_pcall(L, 0, 0, 0); return 0; } This is perfectly legal (and common), and the function is never assigned a name.
  7. Lua require and returning references.....

    Brackets are like the @ symbol in C#, they indicate that the string should be parsed as is, that is without interpreting any escape codes. I used it to avoid escaping the back slash in paths. From the Lua manual: Quote: Literal strings can also be delimited by matching double square brackets [[ ...]]. Literals in this bracketed form may run for several lines, may contain nested [[ ... ]] pairs, and do not interpret any escape sequences. For convenience, when the opening '[[' is immediately followed by a newline, the newline is not included in the string. As an example, in a system using ASCII (in which 'a' is coded as 97, newline is coded as 10, and '1' is coded as 49), the four literals below denote the same string: (1) "alo\n123\"" (2) '\97lo\10\04923"' (3) [[alo 123"]] (4) [[ alo 123"]] It's going to depend on how you bind with Lua and what exactly your cube does, but essentially the NewTemplate function would look like this: function Cube.NewTemplate(path) local cubeTemplate = {} for k, v in pairs(yourPrototypeTable) do cubeTemplate[k] = v end cubeTemplate.properties.texture = path --or whatever needs to be done return cubeTemplate end Where your prototype table is a collection of public methods/properties. Just remember that if you have any fields in the prototype that are a table they'll be shared. Like in your above post: T.properties = Cube.properties Do a deep copy if needed. Example prototype table: local yourPrototypeTable = { Load = function() ... end, CreateAt = function(x, y, z) ... end, }
  8. Lua require and returning references.....

    How about using Game.Cube as a prototype for an intermediate template/factory? Something like: local Cube = require"Game.Cube" --creates a new table that 'inherits' Game.Cube's 'public' methods local BlueCube = Cube.NewTemplate[[..\Content\Models\Blue.bmp]] ... BlueCube.Load() local c = BlueCube.CreateAt(25,0,0)
  9. [LUA] Load script in memory

    That would have been good information to know. As far as I know, in the current release of Lua (5.1.4), all standard load (file/string/buffer/etc) functions eventually go through lua_load.
  10. [LUA] Load script in memory

    Depending on the format of the script in your archive, you may prefer
  11. Resume/Portfolio/Blog Critique

    A short anecdote: I had written several (some popular) WoW addons also. However, I found them extremely difficult to market to potential employers. There are very few Lua only jobs in the industry; most list Lua as a plus but you'll primarily be working in some sort of tool or C++. I ended up dropping all the addons from my portfolio and showed that I could augment C++ with Lua. Shortly thereafter, I had several hits and ended up landing my first industry job. Depending on what exactly you wish to do in the industry, you may consider doing something similar. Consider that many potential employers don't understand WoW addons, let alone guilds, raiding, etc. The UI designs, programming logic, and techniques are more interesting. Try showcasing that instead of the number of downloads.
  12. Problem with Lua

    KillQuest quest1 = new KillQuest("This is a test"); This is not valid Lua. Lua is dynamically typed. More specifically, in Lua, you don't put the type before the variable name. Additionally, "new" is not a keyword in Lua. Try: local quest1 = KillQuest("This is a test"); I'd recommend reading the free Programming in Lua or ordering the second edition.
  13. Changing Lua function metatable

    See: ObjectProperties Do note that these techniques have varying degrees of performance implications.
  14. Quote:Original post by Matthew Shockley I may be wrong, but I believe you have to settable after every time you push a value. You are wrong. settable consumes two values from the stack with each call. You should really test this or at least look at the documentation (which clearly suggests that this is not the case) before providing advice. Quote:Original post by Dummie Data[x]["Key"] = Value; I think this is the same: Data[x].Key = Value; It is, the second way is just syntactic sugar for the first. You'll find that Lua is a very sugary language. Quote: Original post by Dummie Unfortunately nothing happens when I access the created table from Lua. Define "nothing". Quote: It seems my Code is not right. What could be the problem? Where is the mistake? You're pushing strings onto the stack as values when you want to push a table. This is one way to do it, here I've commented what would be on the top of the stack at each point. lua_newtable(L); //Data lua_newtable(L); //Data, subData lua_pushinteger(L, 1); //Data, subData, 1 lua_pushvalue(L, -2); //Duplicate subData - Data, subData, 1, subData lua_settable(L, -4); //Data[1] = subData - (pops 2) Data, subData //setting a field lua_pushstring(L, "v1"); //Data, subData, "v1" lua_setfield(L, -2, "k1"); //subData["k1"] = "v1" - Data, subData //pop off the subtable lua_pop(L, 1); //Data
  15. Calling a Lua function from c++ every frame

    That's not valid Lua. It should look like: function PrintMessage() io.write("...") end You need to check the return value from luaL_dofile so you can catch these sorts of errors. Likely you'd want to use lua_pcall over lua_call and check its return value also.