+ Reply to Thread
Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: X Y grid

  1. #1
    Wire Amateur bubba's Avatar
    Join Date
    Jun 2009
    Posts
    51

    Default X Y grid

    Code:
     [21][22][23][24][25]    5
    
     [16][17][18][19][20]    4
    
     [11][12][13][14][15]    3
    
     [ 6][7 ][ 8][ 9][10]    2
    
     [1 ][2 ][3 ][4 ][5 ]    1
    X 1   2   3   4   5     Y
    Im trying to get a formula to get the X and Y values to equal the numbers inside the square. So I want X2 Y3 to give me 12 and ive tried a ton of things and cant get it to work. My cur one that fails alot is..
    Code:
    SP=(ValX)+(ValY*2)+(ValY*2) - (ValX-1)

  2. #2
    Wire Sofaking Solece's Avatar
    Join Date
    Jul 2008
    Location
    Pittsburgh, PA
    Posts
    673

    Default Re: X Y grid

    Use an table?
    Code:
    R["1,1",number]=22)
    R["2,1",number]=23)
    R["1,2",number]=16)
    etc...

  3. #3
    Wire Amateur bubba's Avatar
    Join Date
    Jun 2009
    Posts
    51

    Default Re: X Y grid

    25 of those can be a pain you know :P I was gonna start with 25 entity markers but thought i should use all E2

  4. #4
    Wire Sofaking N00bDud3's Avatar
    Join Date
    Jul 2009
    Location
    Error: Unknown Location
    Posts
    1,252

    Default Re: X Y grid

    Just start with 1 at the top and go down, and then use Val = X+Y*Width



  5. #5
    Spucatum Tauri Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    6,008

    Default Re: X Y grid

    Val = X+Y*Width is wrong in his case.
    When you fill in his 2 & 3 you get:
    Val = 2 + 3 * 5 = 17

    He starts with 1 instead of 0, it should be:
    Val = X+(Y-1)*Width
    Val = 2 + (3-1) * 5 = 12
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That

    Quote Originally Posted by Anticept View Post
    By the way, Bull is in charge.

  6. #6
    Wirererer Riddler's Avatar
    Join Date
    Nov 2007
    Location
    /dev/null
    Posts
    257

    Default Re: X Y grid

    Bull is right, if you don't put in -1 you get X+Y*Width which when filled in for the first line you get 1+1*5 = 6 so you have 5 memory slots wasted. Arrays using this method still gives 2D and would also have less of a memory footprint than a table with a string index of "1,2"

  7. #7
    Wire Sofaking smellslike's Avatar
    Join Date
    May 2009
    Location
    in a lonley world
    Posts
    412

    Default Re: X Y grid

    Doesnt one of the RAMs act like a xy grid? i remember hearing that from somewhere, i never use them
    Working on military pack.
    Remember
    amateurs build the ark....
    Professionals build the titanic

  8. #8
    Wire Sofaking jacoby6000's Avatar
    Join Date
    Feb 2008
    Location
    behind you when you aren't looking
    Posts
    792

    Default Re: X Y grid

    I hope this doesnt look like im just giving code out O_o
    Code:
    interval(500)
    while(Y<=Height &  ops()<4000)
    X++
    Index=toString(X)+","+toString(Y)
    R[Index,number]=X*Y
    if(X>Width){Y++ X=0}
    There's your basic formula, edit as needed ^_^
    Quote Originally Posted by Garrysmod View Post
    Warning: You're trying to render in the wrong place. This doesn't play nice with multi-core rendering, so we're not going to let you draw here.
    I'm not stupid!
    In [his] experience that was a sentence never to be uttered except to prove its own inaccuracy
    --Orson Scott Card

  9. #9
    Developer Matte's Avatar
    Join Date
    Jan 2009
    Location
    Norway
    Posts
    3,109

    Default Re: X Y grid

    Quote Originally Posted by jacoby6000 View Post
    I hope this doesnt look like im just giving code out O_o
    Code:
    runOnTick(1)
    while(Y<=Height &  ops()<4000)
    {
        X++
        Index=toString(X)+","+toString(Y)
        R[Index,number]=X+(Y-1)*Width
        if(X>Width){Y++, X=0}
    }
    There's your basic formula, edit as needed ^_^
    Fixed.
    "If anybody says he can think about quantum physics without getting giddy, that only shows he has not understood the first thing about them."
    -- Niels Bohr

  10. #10
    Spucatum Tauri Bull's Avatar
    Join Date
    Jun 2008
    Location
    Finland
    Posts
    6,008

    Default Re: X Y grid

    Using a lookup table for that is plain stupid.

    With that, he needs do every time:
    Index = R[ X:toString() + "," + Y:toString() , number ]
    Just to retrieve the index.

    Use:
    Index = X+(Y-1)*Width
    My signature has a point.
    Quote Originally Posted by Squeakyneb View Post
    when l3ulletje says do it, do it.
    That

    Quote Originally Posted by Anticept View Post
    By the way, Bull is in charge.

+ Reply to Thread
Page 1 of 2 12 LastLast

Similar Threads

  1. Grid
    By codemanj94 in forum Wiremod General Chat
    Replies: 3
    Last Post: 07-07-2009, 08:39 AM
  2. How (Grid)
    By Jarviar in forum Installation and Malfunctions Support
    Replies: 4
    Last Post: 05-10-2008, 12:01 PM
  3. Grid on props?
    By Tegro in forum Wiremod General Chat
    Replies: 3
    Last Post: 07-05-2007, 01:35 AM
  4. That Grid thingy
    By kilroy in forum Off-Topic
    Replies: 1
    Last Post: 06-02-2007, 04:15 AM
  5. Holo Grid
    By poco642 in forum Installation and Malfunctions Support
    Replies: 7
    Last Post: 05-10-2007, 08:15 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
proceed-collector
proceed-collector
proceed-collector
proceed-collector
linguistic-parrots
linguistic-parrots
linguistic-parrots
linguistic-parrots