variables and arithmetic in ini files

edited February 2012 in Help request
It feels like I'm spamming the forum but I guess it better to start new threads than to clump them together.
Rotation = @Display.ScreenWidth / 2
Can something like this be done in the ini files? And is there I can get the size of a image or a object like this..
Rotation = @Display.ScreenWidth / 2
Alpha = @AsteroidGraphic.Width

Comments

  • edited February 2012
    No worries for asking questions, that's the goal of the forum anyway. :)

    This has been asked a few times already but it's unfortunately not really easy to implement. That comes from the way inheritance is internally stored/referenced with the config cache.
    When a value is inherited, we'll ask the parent directly and we'll use its own cache (to prevent as many string parsing/interpretation as possible).
    If an expression is referencing a parent, the cache can't be handled by the parent (or any ancestor of the hierarchy) and knowing if something changed somewhere along the hierarchy isn't exactly easy to propagate as the hierarchy itself is a soft one (holes are permitted or even parent-less leaves).
    I'll think about it some more to see if I can find a reasonable solution.

    As for querying the size of an object/graphic directly from the config, this isn't something that can be automated while providing a consistent behavior from the user point of view.

    However you can either pre-process the config or modify it at runtime at will.

    In the case of Rotation, in your Init function you can have something like:
    orxFLOAT fWidth, fHeight;
    orxDisplay_GetScreenSize(&fWidth, &fHeight);
    
    orxConfig_PushSection("MySection");
    orxConfig_SetFloat("Rotation", fWidth / orx2F(2.0f));
    orxConfig_PopSection();
    

    In that particular case (ie. related to screen) you could even have that code when handling the event orxDISPLAY_EVENT_SET_VIDEO_MODE, this way if the screen get resized, your value will always be up-to-date.

    As for the last one with no operator, simply call a orxConfig_SetFloat("Alpha", MyGraphicSize.fX); after retrieving the value from the orxGRAPHIC module.

    All this feels more like you'd need a full fledged scripting system more than simply a config one.
    I know that some users rolled their own LUA bindings, for example, and only develop using LUA.

    That being said, having maths arithmetic expressions could be very useful.
  • edited February 2012
    Yes I guess I have been a bit blinded by the power of the config system. I have been writing a lot of code last week and my program was quite complex then yesterday I rewrote the config system with a better object orientation and realized that I could scrap most of what I had written. =)
  • edited February 2012
    Yeah, using the config system doesn't look that intuitive at first, especially the possibility it brings as well as its limitations.
    I still find tricks in how to use it to make my life better every once in a while. :)

    As for a scripting module, someone started to work on one but it never got finished. Hopefully someone will have time to write one at some point but it's unlikely to be me, at least no in short/med term. =)
  • jimjim
    edited February 2012
    Sorry if my answer is not relevant to the question, it is not a answer anyway. But I think AlgoJerViA , you want scripting feature in ORX. Well, I will be using Lua scripting for my game in ORX. I will be integrating some ORX function to Lua. I don't know anything about ORX module though. So if my integration goes well, I will post in on forum.

    Or you may check Lua or Game Monkey or Squirrel scripting for yourself. Later two can be integrated easily with C++.
  • edited February 2012
    Thanks for the tip but I think I will stay away from scripting for the moment mainly because of my prejudgments. =)But I might look into it later.
  • edited February 2012
    jim wrote:
    Well, I will be using Lua scripting for my game in ORX. I will be integrating some ORX function to Lua. I don't know anything about ORX module though. So if my integration goes well, I will post in on forum.

    Hi jim,

    I'm sure a lot of people (me included) would benefit from some Lua bindings!

    Don't worry about making it a plugin as it's a bit more complex as the API has to be somewhat generic. A good Lua set of bindings is all we need. No pressure though! :)
Sign In or Register to comment.