Skip to main content

On Sale: GamesAssetsToolsTabletopComics
Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(1 edit) (+2)

I think the issue is just your parentheses () placement.  If we look at this line:

elseif (p.hour+1>10) & (p.hour+1<20)

You only need the parentheses to be around p.hour and your +1 adjustment to the time. Putting it in it's own set of parentheses makes sure that this part is done first before the script checks if the number is in the correct range . So you could change that line to be like this instead:

((p.hour+1) >10) & ((p.hour+1) <20)

Hopefully that makes sense?

Optionally, another way to do this would be to modify what p.hour is at the beginning of your script like this:

p:"%p" parse "%e" format sys.now 
utc_offset:1 
p.hour:24%utc_offset+p.hour

The first line is the same as what you have now.

The second line defines a new variable called utc_offset which I'm going to use to say how many hours off from utc your time zone is. (1)

And the third line sets p.hour to be p.hour plus your utc_offset. The 24% in this line keeps the result consistent with 24 hour time. So if the math it was doing for p.hour was 23+1 it would go back to 0 instead of up to 24.

If  this version makes sense to you then you could put this at the beginning of your script and just refer to p.hour for the rest of it without needing to modify it again, because it's already been modified.

(+1)

AMAZING.

It's crystal clear, and it works ! thanks !!

Aaaah I answered too quickly it finally doesn't work :( 

I'm about to give up, I don't understand what I'm doing wrong...

Here is my actual code :

for the hour as you suggested 

on change val do   
end  
on view do   
p:"%p" parse "%e" format sys.now  utc_offset:1  
p.hour:24%utc_offset+p.hour  b:(p.hour)   
me.text:"%f:" format b      
end

and for the button : 


p:"%p" parse "%e" format sys.now   
o:() o.tfont:"f10x20" 
o.border.image:windoid.copy[] 
o.fcolor:colors.white 
o.bcolor:colors.transparent 
o.size:500,0 dd.open[deck o] 
dd.style[o] 
dd.say["+ + + + + INCOMING + + + + +"]  
if (p.hour=12)&(p.minute=13) 
dd.say["EASTEREGG"] 
dd.close[] 
go["card1" "Dissolve"]  
elseif (7=10%p.second) 
dd.say["HACK#7SECONDS#DONTGETCAUGHT#"] 
dd.close[] 
go["card1" "Dissolve"]  
elseif ((p.hour) <10) & ((p.hour) >20) 
dd.say["###ACCES AUTORISE ENTRE 20H ET 10H###"]    
dd.close[]    
go["card1" "Dissolve"]  
else dd.say["###ACCES INTERDIT ENTRE 10H ET 20H###"] 
dd.close[]  
end
(+2)

When you assign a value to a name in an event handler, like this:

on view do
 p:1+2
end

…when Decker decides the thing is being viewed:

  • it calls the view event handler
  • it creates a new name p inside that event handler
  • it assigns the value 3 to p
  • the event handler ends
  • p vanishes along with it

If you have some other event handler somewhere else, like on click do ... end, that event handler does not have access to p, it can’t use the value. If you say p:2*3 in that event handler, it will have its own p that will also vanish when the event handler completes.

In the first code block in your comment, you have:

on view do   
p:"%p" parse "%e" format sys.now  utc_offset:1  
p.hour:24%utc_offset+p.hour  b:(p.hour)
me.text:"%f:" format b      
end

That creates a p with date-time information in it, it adjusts the hour part of that date time, it uses the p for some text formatting, and then the event handler ends and that p is lost.

In your second code-block, which I assume is from a button’s on click do ... event handler, you have:

...
p:"%p" parse "%e" format sys.now
...
if (p.hour=12)&(p.minute=13) 
...

Because that’s a separate event handler, that’s a separate and unrelated p, and its p.hour has not been modified. Every event handler where you want to use the modified time, you need to modify it again.

Also, a little further down:

...
elseif ((p.hour) <10) & ((p.hour) >20) 
...

I don’t think the hour can be less than ten and greater than 20. Perhaps you wanted to switch those around to be “greater than 10 and less than 20”?

Assuming that’s what you want, here’s a button that behaves that way (although it uses Decker’s built-in alert[] rather than the dd.say[] module):

%%WGT0{"w":[{"name":"timelock","type":"button","size":[95,20],"pos":[226,161],"script":"on click do\n p:\"%p\" parse \"%e\" format sys.now  utc_offset:1  \n p.hour:24%utc_offset+p.hour\n\n if ((p.hour) >10) & ((p.hour) <20)\n  alert[\"###ACCES AUTORISE ENTRE 20H ET 10H###\"]\n else\n  alert[\"###ACCES INTERDIT ENTRE 10H ET 20H###\"]\n end\nend","text":"Attempt Unlock"}],"d":{}}

Copy that text to the clipboard, then in Decker you should be able to switch to the widget-editing mode and use Edit → Paste Widgets to add the button to the current card, where you can poke at it.

(+4)

AND NOW IT WORKS 

thanks everyone for your infinite patience