Genesis Forums

Tick Trigger
Page 1 of 1

Author:  Kwevin [ 12 Apr 2016 06:08 ]
Post subject:  Tick Trigger

Hello all. I am clueless in the language of Java, so I need help. How would I make a tick trigger?
What would you put in the pattern?
Also, how big is the number for one second?

Author:  Mayobe [ 12 Apr 2016 14:06 ]
Post subject:  Re: Tick Trigger

JS and Java are 110% separate animals. (

Triggers in the web client cannot be set to fire on a timer (yet) without some serious fiddling around.

JS is very easy to learn as far as languages go. The W3 tutorials should be enough to get you started.

Note that this is a very widely used language, so it's worth picking up a bit in any case. I think someone linked you the gwc thread in your other question, which discusses the unique functionality of the Genesis web client.

What is it that you want to use a timer for? There may be a different approach that would be less work.

Author:  cotillion [ 12 Apr 2016 15:56 ]
Post subject:  Re: Tick Trigger

You can easily create tick triggers.

Just create a trigger on something like 'Welcome to Genesis' to start it.

Author:  Kwevin [ 12 Apr 2016 16:20 ]
Post subject:  Re: Tick Trigger

Oh, yeah, I found that. But, my question is, how many ticks in one second? My guess was something like 1000?

Author:  Melarec [ 12 Apr 2016 16:54 ]
Post subject:  Re: Tick Trigger

Tick is measured in milliseconds, so yes 1000 is once per second.
function eatHerb() {
    gwc.connection.send("eat herb");
This will eat an herb every 5 seconds.
It may actually need something to initially set it off, though.. I've not experimented with JS in Genesis, but that would call "eatHerb" once per five seconds if this were web-design..

Attached is a clock I designed with JS.. It relies heavily on the ability to tick. Uncompress and open the "clockRun" HTML file in your browser.. Or in Notepad if you want to see the skeleton code.

EDIT: 5 seconds, not 5000..

G Clock - [21.64 KiB]
Downloaded 86 times

Author:  Kwevin [ 12 Apr 2016 18:57 ]
Post subject:  Re: Tick Trigger

Ahh, okay. I think I have this down pretty well.

Is there a simple way to color just one word, not the whole line?

Author:  Mayobe [ 12 Apr 2016 21:02 ]
Post subject:  Re: Tick Trigger

Oh? I didn't know there was a callback timer like that. Will the functions persist outside the script execution?

Sort of complicated text coloring script:
Trigger (regex): (words|or phrases|that|I'm watching|for)
gwc.output.replace(RegExp(args[1], 'g'), '<span style="background-color: red; color: lime;">'+args[1]+'</span>', true);

Less complicated:
Trigger (plain): orc
gwc.output.replace(/(\s(orcs|orc)[\s|\.|,])/gi, '<span style="color: darkseagreen">$1</span>', true);

Author:  Melarec [ 12 Apr 2016 23:18 ]
Post subject:  Re: Tick Trigger

Just a quick note..
Don't set a trigger's pattern to " " . (The blank space between words)
I seriously bogged down my client..

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group