Tick Trigger

General discussion about the Genesis Web Client located at https://www.genesismud.org/play/

Moderator: Eowul

Forum rules
- Use common sense and be respectful towards each other at all times, even when disagreeing.
- Do not reveal sensitive game information. Guild secrets, player seconds are examples of things not allowed.
Post Reply
Kwevin
Veteran
Posts: 207
Joined: 21 Mar 2016 09:17

Tick Trigger

Post by Kwevin » 12 Apr 2016 06:08

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?
Alea iacta est. Serius regredi est.

User avatar
Mayobe
Adept
Posts: 133
Joined: 23 Jan 2016 08:28
Location: Bree

Re: Tick Trigger

Post by Mayobe » 12 Apr 2016 14:06

JS and Java are 110% separate animals. (http://stackoverflow.com/questions/2450 ... t-and-java)

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.

http://www.w3schools.com/js/

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.

User avatar
cotillion
Site Admin
Posts: 350
Joined: 04 Mar 2010 01:14

Re: Tick Trigger

Post by cotillion » 12 Apr 2016 15:56

You can easily create tick triggers.

Just create a trigger on something like 'Welcome to Genesis' to start it.
https://www.genesismud.org/forums/viewt ... ick#p22245

Kwevin
Veteran
Posts: 207
Joined: 21 Mar 2016 09:17

Re: Tick Trigger

Post by Kwevin » 12 Apr 2016 16:20

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

User avatar
Melarec
Rising Hero
Posts: 318
Joined: 29 Feb 2016 19:51
Location: Everywhere
Contact:

Re: Tick Trigger

Post by Melarec » 12 Apr 2016 16:54

Tick is measured in milliseconds, so yes 1000 is once per second.

Code: Select all

setInterval(eatHerb,5000);
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..
Attachments
G Clock - Cmprssd.zip
(21.64 KiB) Downloaded 202 times
Last edited by Melarec on 12 Apr 2016 21:58, edited 1 time in total.

Kwevin
Veteran
Posts: 207
Joined: 21 Mar 2016 09:17

Re: Tick Trigger

Post by Kwevin » 12 Apr 2016 18:57

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

Is there a simple way to color just one word, not the whole line?
Alea iacta est. Serius regredi est.

User avatar
Mayobe
Adept
Posts: 133
Joined: 23 Jan 2016 08:28
Location: Bree

Re: Tick Trigger

Post by Mayobe » 12 Apr 2016 21:02

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:

Code: Select all

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:

Code: Select all

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

User avatar
Melarec
Rising Hero
Posts: 318
Joined: 29 Feb 2016 19:51
Location: Everywhere
Contact:

Re: Tick Trigger

Post by Melarec » 12 Apr 2016 23:18

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

Post Reply
http://tworzymyatmosfere.pl/przescieradla-jedwabne-z-gumka/