+day1976 Posted February 13, 2017 Share Posted February 13, 2017 OK, so my first question on here. I have built a few wherigos so far, all using urwigo but I am not afraid to dabble in some lua user functions and lua exprressions too. I am interested in creating some zones that move and I have been able to do this so they move to specific locations, BUT, I would like to base the zones location on a variable (namely the minute of the day). I have looked through these forums and I have uncovered some really useful stuff, but I can't seem to find this specific thing. Although I am sure it can be done. So, I figure that if the minute of the day can be divided by 1440 (the number of minutes of the day) and then multiplied by 360, we can get a degree that could be the bearing. Keeping the distant constant, then the zone should be able to move in a circle around a specified position. As I said I am sure this can be done but some advice on how I can write this into the lua functions and implement them on urwigo would be very much appreciated. Kind Regards Day (day1976) Quote Link to comment
Ranger Fox Posted February 14, 2017 Share Posted February 14, 2017 If you've looked into moving zones, you should have come across the TranslatePoint method by now. It accepts a ZonePoint, distance, and bearing. You can add your bearing there, so TranslatePoint(point, distance, (((hour + 1) * minute) / 1440) * 360) or something like that, supposing midnight is a zero hour. As far as getting the time, os.time() should return the current time. I'm not sure if you can just do os.date("*t").min, but you can start searching the online lua documentation from there. That's what I'd do, at least. Quote Link to comment
+day1976 Posted February 15, 2017 Author Share Posted February 15, 2017 Thankyou RangerFox, That now works perfectly. I will try and post a demo urwigo project on here for people if they are interested. Kind Regards day1976 Quote Link to comment
+day1976 Posted February 15, 2017 Author Share Posted February 15, 2017 OK, here is my rough urwigo project (with the final cache location removed). So, Ummel the dragon flies a 360 degree circle, once a day. Radius of the circle is 100 kilometers. You need to get within 1 kilometer of Ummel (the size of the zone) The device that you have to find Ummel doesn't tell you how far away you are, only the direction (bearing) to him. So you need to triangulate Ummels position, and update as the zone moves around. The zone updates its new position every 5 seconds. Hope someone gets something out of this, it was fun to build, now to just put some meat on it and send it off for publication. Dragon Hunter.zip Quote Link to comment
+day1976 Posted February 16, 2017 Author Share Posted February 16, 2017 And I thought I had it all under control! So the above urwigo project works quite well. Ummel flies around in a circle with a 100 kilometer radius. But I wanted to be a bit more tricky (usually is always my downfall). So I created a variable called DistanceToZone. I gave it an identifier called distancetozone. The variable DistanceToZone is dependent on two things. The first being the day of the month (which means as the month goes on the radius of the circle increases) and also what the bearing is (which makes it a flattened oval shape, rather than a circle). I have checked all of this and I am happy that the correct value for DistanceToZone is being calculated because it pops up as a small dialog box right before I call the function. I then call the lua function MoveZone and give it the centrezone Original Point (the desired centre of the oval), I give it the calculated value for the bearing and the distance. I then give these three the names point, bearing and length (because I didn't want to confuse myself with the other variable "dist"). Anyway, the only thing that I have changed in this function is on line 21, which used to ready dist = Wherigo.Distance(100000,units). It now reads dist = Wherigo.Distance(length,units). But it doesn't work. Even though I know the variable DistanceToZone has a value of 140,000 (at the time I was checking it), the zone is not moving and is sitting at the centrezone location as though the value for length is 0. I had thought that the identifier distanceofzone or the variable length might be used elsewhere, so I have tried other random words in their place and I still get 0. I have attached a image of what I have done. If anyone can offer some help, it would be gratefully accepted. Kind Regards day1976 Quote Link to comment
+day1976 Posted February 21, 2017 Author Share Posted February 21, 2017 Never mind, I figured it out. Silly mistake. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.