- Joined
- Sep 7, 2020
- Posts
- 14
I'm pretty unfamiliar with Essentials and Ruby and am trying to implement a mechanic to make apricorn trees grow according to a timer.
To do so, I have a time_event_hash variable meant to contain every time-sensitive event where each entry would be a combination where the key is an event's unique id and the value is the time at which said apricorn's growth would be complete (in unix time).
I then have a loop in my event that compares the current unix time to the time at which the growth on my apricorn is meant to be reached by using this function:
However, it makes my game crash, telling me that it can't compare an integer with a Nil value, implying that either the time_event_hash[get_time_event_id] == Nil, or that the key associated to my apricorn tree doesn't even exist.
To make sure of it, I decided to check if my hash contains the appropriate key and print the content of said hash in the command prompt if it doesn't.
Here is my code:
And here is what it printed out:
Thanks in advance.
To do so, I have a time_event_hash variable meant to contain every time-sensitive event where each entry would be a combination where the key is an event's unique id and the value is the time at which said apricorn's growth would be complete (in unix time).
I then have a loop in my event that compares the current unix time to the time at which the growth on my apricorn is meant to be reached by using this function:
Code:
pbGetTimeNow.to_i >= time_event_hash[get_time_event_id]
To make sure of it, I decided to check if my hash contains the appropriate key and print the content of said hash in the command prompt if it doesn't.
Here is my code:
Ruby:
if time_event_hash.key?(get_time_event_id)
echoln "%s not found in hash!" % get_time_event_id
echoln "%s" % time_event_hash
end
Does anyone know why I can't find my key in my hash while it clearly has it and what the solution to that problem could be?apricorn_tree_6_10 not found in hash!
{"apricorn_tree_6_10"=>1751460881}
Thanks in advance.