Hello helpers,
First of all, I'm new to programming and everything is not easy for me, so sorry if my question seems stupid but after several searches (days ;-() I have not been able to find (or understand :-)) the solution to my problem.
I wanted to insert a date system in my story and this javascript code works well
/* A method to change a date using intervals */
if (! setup.changeDate) {
setup.changeDate = function(date, interval, units) {
var d = new Date(date); // Don't change original date.
switch(interval.toLowerCase()) {
case 'years':
d.setFullYear(d.getFullYear() + units);
break;
case 'quarters':
d.setMonth(d.getMonth() + 3 * units);
break;
case 'months':
d.setMonth(d.getMonth() + units);
break;
case 'weeks':
d.setDate(d.getDate() + 7 * units);
break;
case 'days':
d.setDate(d.getDate() + units);
break;
case 'hours':
d.setTime(d.getTime() + units * 3600000);
break;
case 'minutes':
d.setTime(d.getTime() + units * 60000);
break;
case 'seconds':
d.setTime(d.getTime() + units * 1000);
break;
default:
break;
}
return d;
};
}
with these indications
Example of using the setup.changeDate to change game time.
original date: <<print $now>>
<<set $now to setup.changeDate($now, 'minutes', 15)>>
Added 15 minutes of game time: <<print $now>>
<<set $now to setup.changeDate($now, 'hours', 2)>>
Added 2 hours of game time: <<print $now>>
but I can't find a way to add 1 hour when I click on a link or image as you can easily do with a variable
example if you are in a passage named test with a variable $hour
[[add 1 hour | test] [$hour += 1]]
I don't have the right synthax to change the time. So does someone know it ? Or maybe it's not a synthax issue and in this case i'm lost. I have already test the widget time but same issue.
The second concern will be to only update the variable without refreshing the whole page but it will be for another post after readings and research i guess ;-)