Immediate commands in config

67 views
Skip to first unread message

iarwain

unread,
Apr 19, 2013, 9:37:59 PM4/19/13
to orx...@googlegroups.com
Hey all,

I was wondering if any of you would be interested in a new feature that would allow you to execute commands immediately when a config file is parsed.
That would be helpful as an alternative to missing features of the config format (such as in-value inheritance: ScreenResolution = (@Display.ScreenWidth, @Display.ScreenHeight, @Display.ScreenDepth), config operators: BufferSize = @Display.ScreenWidth * @Display.ScreenHeight, etc...).

The syntax would be something like:

[Display]
ScreenWidth = 1680
ScreenHeight = 1050
ScreenDepth = 32

; Sets value for MySection.ScreenResolution
! > Config.GetValue Display ScreenDepth
! > Config.GetValue Display ScreenHeight
! > Config.GetValue Display ScreenWidth
!    Config.SetValue MySection ScreenResolution "(<, <, <)"

; Sets value for MySection.BufferSize
! > Config.GetValue Display ScreenWidth
! > Config.GetValue Display ScreenHeight
! > * < <
!    Config.SetValue MySection BufferSize <

The issue is that if Display.* changes values over time, the value of MySection.* won't get updated as with standard inheritance. And of course you can use commands for doing conditional loading of config files or even create objects and code a whole game there if you feel that courageous. ;)

Any thoughts/comments?

Cheers,

Rom

Philippe Simons

unread,
Apr 22, 2013, 4:29:04 AM4/22/13
to orx...@googlegroups.com
could be interesting, but honestly i don't see a problem doing all this in my Init() function.
personally, I would prefer to see some love to issue #19 free-form deformation :p



--
You received this message because you are subscribed to the Google Groups "orx-dev" group.
To post to this group, send email to orx...@googlegroups.com.
Visit this group at http://groups.google.com/group/orx-dev?hl=en.
 
 

orx-project

unread,
Apr 22, 2013, 3:00:15 PM4/22/13
to orx...@googlegroups.com
Hehe, noted. :)


2013/4/22 Philippe Simons <simons....@gmail.com>

iarwain

unread,
Feb 26, 2014, 4:15:45 PM2/26/14
to orx...@googlegroups.com
Well, as it wasn't very hard to implement, I implemented it 2 weeks ago: https://bitbucket.org/orx/orx/issue/56/add-support-for-in-config-command

The only difference from the draft above is that I use the character % instead of ! to prefix an in-config command.

I'm actually using it in my own projects in a few places. Usually to only have one variable to tweak when making tests. Let's say I have an object that I want to fade-out before it disappears. Disappearance being controlled by a LifeTime property, but I'm not sure how long I want those objects to live.
Instead of tweaking both the LifeTime and the FadeOut FX times, I use in-config commands to automate the process.

Here's a simple example:

[Particle]
LifeTime = 10
Alpha = 0
FXList = @
SlotList = FadeIn # FadeOut

[FadeIn]
Type = alpha
Curve = smooth
StartValue = 0
EndValue = 1
StartTime = 0
EndTime = 0.5

; So far, nothing unusual

[FadeOut@FadeIn]
EndValue = -1
EndTime = @Particle.LifeTime ; Here I can use traditional inheritance
; However I can't use @ for the StartTime as it basically is LifeTime - 0.5, and thus depends on more than LifeTime's value alone
; Here's how to do it:
% > Config.GetValue Particle LifeTime         ; Gets Particle.LifeTime and pushes it on stack
% > - < 0.5                                                ; Subtract 0.5 from it and pushes it on stack
%    Config.SetValue FadeOut StartTime <   ; Sets FadeOut.StartTime with the result

Lemme know if you have any questions! =)

Cheers,

Rom

Jim

unread,
Mar 4, 2014, 11:32:47 AM3/4/14
to orx...@googlegroups.com
Oh man, I needed this, this would have saved me a tons of same rewrites while working on that 9 scale system. But now that it's here. I should put it on the weekend checklist ;) One thing, is it possible to extract values from Vector? Like

[9Scale]
TopLeft = (100,100,0)
BottomLeft = (200,200,0)

And I want to use

[Test]
Size = (@BottomLeft[0]- @TopLeft[0], @BottomLeft[1]- @TopLeft[1], 0)

I can simply provide TextureSize, but I am giving here just an example. This could be used to derive any values once, during parse time.

orx-project

unread,
Mar 4, 2014, 11:47:50 AM3/4/14
to orx...@googlegroups.com
It will as soon as I'm able to add commands to extract vector
components but those commands do not exist yet. =)

The syntax will stay consistent with other commands though (given it's
not a language per se, just a sequence of commands):

Vector.X
Vector.Y
Vector.Z

Don't mind the capitalization, commands are evaluated in a
case-insensitive way, so VECtor.x would work just as well. ;)

However, in your example, you don't really need them. You can already use:

[9Scale]
TopLeft = (100, 100, 0)
BottomLeft = (200, 200, 0)

% > get 9Scale TopLeft ; Pushing 9Scale.TopLeft
% > get 9Scale BottomLeft ; Pushing 9Scale.BottomLeft
% > - < < ; Pushing 9Scale.BottomLeft - 9Scale.TopLeft
% set Test Size < ; Putting result into Test.Size

Cheers!

Rom
> --
> You received this message because you are subscribed to the Google Groups
> "orx-dev" group.
> To post to this group, send email to orx...@googlegroups.com.
> Visit this group at http://groups.google.com/group/orx-dev.

Jim

unread,
Mar 4, 2014, 12:32:58 PM3/4/14
to orx...@googlegroups.com
This is a great feature. First I was thinking of parsing and setting some data manually in init() or the first time it's loaded, because writing hard value is cumbersome in some cases. But this is too awesome :D
Reply all
Reply to author
Forward
0 new messages