Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
4 registered members (AndrewAMD, Quad, soulman3, Ayumi), 675 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
GPS - Grid #205828
05/09/08 00:15
05/09/08 00:15
Joined: May 2008
Posts: 27
x10d3 Offline OP
Newbie
x10d3  Offline OP
Newbie

Joined: May 2008
Posts: 27
Was wondering if anyone could give me some insight on a project that I would like to complete. I want to cut a map into a "Grid" so that I can have some sort of display where it says something like you are in "B3". How can I accomplish this?

Re: GPS - Grid [Re: x10d3] #205864
05/09/08 08:31
05/09/08 08:31
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Well one possibility would be to have a "simulated" grid (so to speak).
You just need to calculate the quadrant from the player position (x, y) and then use an array to replace those.
Example:
I make a grid where each quadrant is 100 width and 100 height (x, y).
Furthermore I set up two string arrays which hold the quadrant_x and quadrant_y name. (can be anything like "Alpha" and "Romeo" or whatever)
Then we divide the players x/y position by the width/height of the quadrants and use the integer part of it to get the quadrant name from those string arrays.
(NOTE: The following code is C-Script and not tested!)
 Code:
var quadrant_size[2] = 100,100;
string quadrant_name = "#2";

text quadrant_x
{
  strings = "A","B","C","D","E","F","G";
}

text quadrant_y
{
  string = "1","2","3","4","5","6","7";
}

function get_quadrant()
{
  var _x;
  var _y;

  _x = int(abs(my.x/quadrant_size.x));
  _y = int(abs(my.y/quadrant_size.y));

  str_cpy(quadrant_name,quadrant_x.string[_x]);
  str_cat(quadrant_name,quadrant_y.string[_y]);
}

Now call the get_quadrant() function from within a while loop of your player or whatever and use the quadrant_name to display the location.

Re: GPS - Grid [Re: Xarthor] #208712
05/28/08 23:55
05/28/08 23:55
Joined: May 2008
Posts: 27
x10d3 Offline OP
Newbie
x10d3  Offline OP
Newbie

Joined: May 2008
Posts: 27
Hey thanx! I am just now able to get back to this. so I tried it out and I get an error with this part during start up

text quadrant_x
{
strings = "A","B","C","D","E","F","G";
}

text quadrant_y
{
string = "1","2","3","4","5","6","7";
}


I am getting a syntax error on quadrant_x

Re: GPS - Grid [Re: x10d3] #208717
05/29/08 01:30
05/29/08 01:30
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
I don't think "strings" is part of a text object, it should be "string".

Last edited by DJBMASTER; 05/29/08 01:30.
Re: GPS - Grid [Re: DJBMASTER] #208736
05/29/08 08:24
05/29/08 08:24
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Yep. DJBMASTER is correct. It should be "string" just like in quadrant_y, sorry for the typo.

@DJBMASTER:
"strings" is a part of a text object aswell, but represents the number of strings included in a text object.
Example:
Code:
text dummy_txt
{
  strings = 100;
}

That snippet creates a text object with 100 strings, thus can be used as a string array with 100 elements.

Re: GPS - Grid [Re: Xarthor] #209437
06/03/08 01:26
06/03/08 01:26
Joined: May 2008
Posts: 27
x10d3 Offline OP
Newbie
x10d3  Offline OP
Newbie

Joined: May 2008
Posts: 27
Maybe I have this in the wrong place. I am using "C:\Program Files (x86)\GStudio7\template_6\code\plBiped01.wdl" as a base template. How would I add this script to it. It seems like my.x and my.y keep coming up empty.

Re: GPS - Grid [Re: x10d3] #209446
06/03/08 04:34
06/03/08 04:34
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
You need to either integrate the function call in the while loop of the plBiped player entity action, or you write a new function:
Code:
function run_GridSys()
{
  // the entity pointer to the player (not sure here as I don't work with the templates
  my = plBiped01;

  while(me)
  {
    get_quadrant();
    wait(1);
  }
}


Re: GPS - Grid [Re: Xarthor] #210111
06/08/08 01:18
06/08/08 01:18
Joined: May 2008
Posts: 27
x10d3 Offline OP
Newbie
x10d3  Offline OP
Newbie

Joined: May 2008
Posts: 27
I am not doing something right.

I have set

Code:
string quadrantX = "0";
string quadrantY = "0";


above main()

and below it I set a panel and I am trying to display just 0 0 and can't get that. All I seem to get is (null)

Code:
digits(1100,80,"Latitude: %s",*,2,quadrantX);   	
digits(1100,90,"Longitude: %s",*,2,quadrantY); 


Re: GPS - Grid [Re: x10d3] #211104
06/14/08 22:40
06/14/08 22:40
Joined: May 2008
Posts: 27
x10d3 Offline OP
Newbie
x10d3  Offline OP
Newbie

Joined: May 2008
Posts: 27
OK.. I got this working.. It was a mix of a lot of things. I am just using the my.x and my.y... I was wondering though does anyone know how to do directions. Like North, South, East, West?


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1