Efficient way to compare player X,Y with other objects X,Y from tables.

I've tried somethig like this:

Every 0.1second check If Player X,Y = X,Y from Table if YES DoSomething
Otherwise go to next raw and repeat behavour.

It works but it slows down everything, that the game drops a lot fps... It's useless. No matter how many rows you have.
Is there any way to make such massive comparison between player and X,Y from tables?

Answers

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2012

    @danielhalat

    Hi Daniel, I'm thinking that to check a list would take far less time than 0.1 seconds (providing there weren't thousands of entries), so maybe try dispensing with the timer and put the checking on a loop; to see if that improves fps at all.

    So make an integer, let's call it Loop

    When Loop is 0
    ---your table check rules here, checking row rowCheck
    When x,y = x,y
    Change attribute Loop to 2
    ---do something, including Change attribute RowCheck to 1 presumably ---
    Otherwise
    Change attribute Loop to 1

    ----

    Rule: When Loop = 1
    Change attribute RowCheck to rowCheck+1
    Change attribute Loop to 0

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • DanielDoeDanielDoe Member Posts: 307
    That sounds ok, but I can't make a loop in one Rule that works (or I don't know how).
    If rule once check the value e.x. If Rule=0 it don't execute next time when Rule=1, Rule=2, Rule=3.

    I don't know if this is clear so please check the project:
    https://www.dropbox.com/s/gxve8nevhzfj81c/thelastjourney 0.1.50.zip
    The actor that compares positions is spaceSpawner.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2012
    That sounds ok, but I can't make a loop in one Rule that works (or I don't know how).
    If rule once check the value e.x. If Rule=0 it don't execute next time when Rule=1, Rule=2, Rule=3.
    OK, that's why the Loop I've used has three places - 0,1 & 2 - 0 and 1 is the loop, and 2 stops the loop when it's found a match.

    I'll take a look at your gamefile and see what I can do; I'll try to get around to it tonight (it's 7.40pm UK time at the moment here) but if not tonight, tomorrow; hope that's OK with you.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • DanielDoeDanielDoe Member Posts: 307
    Thanks a lot! I'll wait for that.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi Daniel, I can't find your rules where it's checking every 0.1 secs....

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • DanielDoeDanielDoe Member Posts: 307
    It's in spaceSpawner actor - second Rule (named just Rule).
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited November 2012

    Thanks, but in the version you sent me, there's no Timer behaviour checking every 0.1 seconds as you said.... unless I'm going slightly crazy and it's there and I can't see it....

    This is your second rule I'm seeing in the spaceSpawner actor:

    Photobucket

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • DanielDoeDanielDoe Member Posts: 307
    edited November 2012
    Sorry, did't noticed that this is version where I was already trying to make a Loop as in your first post. Previously this whole Rule was just a Every 0,1s Timer.

    So the Rule where is comparison between planetIndex and self.temp_index was de facto timer before. Hope this will help. Your screenshot shows the Rules that compares X,Y with tables and these are inside this general Loop/Timer Rule.
  • DanielDoeDanielDoe Member Posts: 307
    Ok so I've made the loop from your first post. I think I've made it exactly as described and still the loop don't want to restart after first execution.

    If you have few minutes please check the new project file:
    https://www.dropbox.com/s/h9sd5jaywj1fi7v/thelastjourney 0.2.00.zip
Sign In or Register to comment.