Global Value

Undocumented configurations

Global Value

Postby theApex on Fri Feb 13, 2009 3:27 am

Is there a way to set a variable to true at the begining of the script. For example:

#farm=true

and then

<strategy class="Farmizzator" desc="Farm -103|34" enabled="#farm">
$$$$$$$$$$$$$$$$$$$$$$PARAMITERS$$$$$$$$$$$$$$$$$$$$$$$
</strategy>
<strategy class="Farmizzator" desc="Farm -104|34" enabled="#farm">
$$$$$$$$$$$$$$$$$$$$$$PARAMITERS$$$$$$$$$$$$$$$$$$$$$$$
</strategy>
<strategy class="Farmizzator" desc="Farm -107|34" enabled="#farm">
$$$$$$$$$$$$$$$$$$$$$$PARAMITERS$$$$$$$$$$$$$$$$$$$$$$$
</strategy>
etc...

so i dont have to manualy change the value to true in every single strategy, i can just do it once globaly
theApex
 
Posts: 16
Joined: Mon Dec 01, 2008 5:59 am

Re: Global Value

Postby xtian on Sat Feb 21, 2009 11:14 am

This is a good idea.
We're using Commons Configuration for the config file, and the docs say you can do what you need: http://commons.apache.org/configuration/userguide/howto_basicfeatures.html#Variable_Interpolation
The examples given are for properties files, but we are using an XML file, so I can't tell you for sure how to do it before I try it myself.
I guess you could do something like

Code: Select all
<configuration>
   <farmFlag>true</farmFlag>
           etc.
           <strategy enabled="{$configuration.farmFlag}">


Try it and let us know!
User avatar
xtian
Site Admin
 
Posts: 1431
Joined: Sun Nov 23, 2008 4:48 pm
Location: Italy

Re: Global Value

Postby just84 on Sun Feb 22, 2009 3:40 pm

Thank's !!!!!
This works great!!!!
saves you lots of time....

*updated
sorry about that seems not to work, it's just completely remove the strategy, no errors...
maybe we should put it in the language file....?
just84
 
Posts: 55
Joined: Mon Dec 01, 2008 2:09 pm

Re: Global Value

Postby just84 on Fri Feb 27, 2009 2:22 pm

OK,
I have tried to put it in the language file as key.buildflag , and buildflag .
Also i have tried to put it in my configuration as {$language-us.buildflag} , {$language-us.properties.buildflag} , {$buildflag} and buildflag.
Also tries every thing with the '$' sign before the '{' (as it is writing in the link you gave...)
none of it work...
but I do think this can help a lot if we would find out how to use it...
just84
 
Posts: 55
Joined: Mon Dec 01, 2008 2:09 pm

Re: Global Value

Postby Die_Papa on Sun Oct 25, 2009 9:30 pm

Hi Xian!

I still think this is a very useful idea...
Any news wether you are implementing this,, and if so, when you plan to have a distro available (approximately offcourse)

Thx.
Die_Papa
 

Re: Global Value

Postby xtian on Mon Oct 26, 2009 10:14 pm

I just realised I made a mistake in my first example.

Wrong:

Code: Select all
<configuration>
<farmFlag>true</farmFlag>
<strategy enabled="{$configuration.farmFlag}">


Correct:
Code: Select all
<configuration>
<farmFlag>true</farmFlag>
<strategy enabled="${farmFlag}">


Note that the dollar sign comes BEFORE the braces, and also "configuration." shouldn't be there.

I still haven't tried it though. :mrgreen:
User avatar
xtian
Site Admin
 
Posts: 1431
Joined: Sun Nov 23, 2008 4:48 pm
Location: Italy

Re: Global Value

Postby Die_Papa on Tue Oct 27, 2009 4:26 pm

I've tried this but can't get it to work.
I also tried removing the quotes, but that results in a hard error.
Die_Papa
 

Re: Global Value

Postby 7ou2 on Wed Jul 14, 2010 1:54 pm

same to me.

my nanny say strategy enabled. but she never run that strategy. :cry:
7ou2
 
Posts: 12
Joined: Wed Jun 16, 2010 6:37 pm

Re: Global Value

Postby fofo on Sat Jul 17, 2010 3:17 pm

The example xtian linked to above says this:
application.name = Killer App
application.version = 1.6.2

application.title = ${application.name} ${application.version}

so in our case I would guess
farm.enable = true
<configuration>
<strategy enabled="${farm.enable}">

would be our conversion of that example
edit:
I can't make this work :(

to turn things on or off, I usually comment it away to turn it off, <!-- means start of comment, and --> is end of comment.
you can not nest comments. This is how it would look with the 3 farmizzator routines NOT running
<!--
<strategy class="Farmizzator" desc="Farm -103|34" enabled="true">
$$$$$$$$$$$$$$$$$$$$$$PARAMITERS$$$$$$$$$$$$$$$$$$$$$$$
</strategy>
<strategy class="Farmizzator" desc="Farm -104|34" enabled="true">
$$$$$$$$$$$$$$$$$$$$$$PARAMITERS$$$$$$$$$$$$$$$$$$$$$$$
</strategy>
<strategy class="Farmizzator" desc="Farm -107|34" enabled="true">
$$$$$$$$$$$$$$$$$$$$$$PARAMITERS$$$$$$$$$$$$$$$$$$$$$$$
</strategy>
-->

fofo
fofo
 
Posts: 134
Joined: Sat Nov 29, 2008 9:18 pm


Return to Tips and Secrets

Who is online

Users browsing this forum: No registered users and 1 guest


cron
VilloNanny Travian Bot VilloFetch Web Proxy - Unblock Travian Cristian Ghezzi Web Site SourceForge.net Logo