0 Favourites

# How do I make a Sine Period key value-sensitive?

• 8 posts
• I'm making a simulation RPG, where the user levels up different attributes of a character throughout the game. In it, there's a mini-game in which a meter oscillates back and forth, and the user has to stop it on a particular area to get the most points.

What I want to do is make this meter's oscillation speed be inverse to their attribute point rating (so like, 'attention level 20/100' would make the meter fast, while 'attention level 80/100' would make the meter slow, etc.).

I'm trying to just set the actual Sine wave Period of my meter to a Dictionary key value, divided by a number. I.E.:

• Dictionary.Get("attention") / 50

But the expression is not working mathematically. It just calls the value previously stored for 'attention', but doesn't do the division math.

>dictionary set key "attention" value (your value here)

Every tick> (your sprite here) set sine period to Dictionary.Get("attention")/50

This will work, maybe you did not add the key, before setting the value?

• sizcoz, I declare/define the key in another layout, and when I'm running the test I start with that layout in order to properly run through the workflow.

Am I not supposed to have spaces around the operators (for divide, add, subtract, etc.)? In the C2 manual they put spaces around the operators when they do operations like this. [Ex: (Player1.X + Player2.X) / 2]

Also, is adding a key and setting a key, for the purposes of what I'm trying to do, not the same thing?

System > Every Tick > [sprite name] > Set Sine Period to Dictionary.Get("attention")

____________________ > [sprite name] > Set Sine Period to [sprite name].Sine.Period / 50

But that seems to give me an error:

After I cancel it, it actually gives me the values I was looking for...but what does that error mean?

• It looks like a bug which would be good to report.

You can probably work around it by using :

float(Dictionary.Get("attention")) instead of Dictionary.Get("attention"). I'm guessing the value of "attention" isn't a number, or at least isn't right away.

• The value was stored as a number, and when I debug the dictionary, it was being returned as a number (integer), so I'm not sure what the problem was. I'll try that though, and I guess add the bug >> at some point