View unanswered posts | View active topics It is currently 12 Dec 2017 08:21

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.



Reply to topic  [ 8 posts ] 
Tick Trigger 
Author Message
Veteran

Joined: 21 Mar 2016 09:17
Posts: 205
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.


12 Apr 2016 06:08
Profile
Adept
User avatar

Joined: 23 Jan 2016 08:28
Posts: 133
Location: Bree
JS and Java are 110% separate animals. (http://stackoverflow.com/questions/245062/whats-the-difference-between-javascript-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.


12 Apr 2016 14:06
Profile
Site Admin
User avatar

Joined: 04 Mar 2010 01:14
Posts: 265
You can easily create tick triggers.

Just create a trigger on something like 'Welcome to Genesis' to start it.
viewtopic.php?f=37&t=2587&p=22245&hilit=tick#p22245


12 Apr 2016 15:56
Profile
Veteran

Joined: 21 Mar 2016 09:17
Posts: 205
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.


12 Apr 2016 16:20
Profile
Rising Hero
User avatar

Joined: 29 Feb 2016 19:51
Posts: 311
Location: Everywhere
Tick is measured in milliseconds, so yes 1000 is once per second.
Code:
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 52 times

_________________
Chillin
[-_- ]
Click here to become a pupil of my Brute! It's really cool, I swear.


Last edited by Melarec on 12 Apr 2016 21:58, edited 1 time in total.

12 Apr 2016 16:54
Profile WWW
Veteran

Joined: 21 Mar 2016 09:17
Posts: 205
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.


12 Apr 2016 18:57
Profile
Adept
User avatar

Joined: 23 Jan 2016 08:28
Posts: 133
Location: Bree
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:
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:
Trigger (plain): orc
gwc.output.replace(/(\s(orcs|orc)[\s|\.|,])/gi, '<span style="color: darkseagreen">$1</span>', true);


12 Apr 2016 21:02
Profile
Rising Hero
User avatar

Joined: 29 Feb 2016 19:51
Posts: 311
Location: Everywhere
Just a quick note..
Don't set a trigger's pattern to " " . (The blank space between words)
I seriously bogged down my client..

_________________
Chillin
[-_- ]
Click here to become a pupil of my Brute! It's really cool, I swear.


12 Apr 2016 23:18
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software.