Wave logic with images

Hello friends, I have a problem that I can not solve, I was wondering if someone could help me. But the problem is this, I have an images that change depending on the tables, ie

Row 1 - picture 1

Row 2 - image 2

Row 3 - image 3

etc

the problem is that I have a rule that all pictures will rotate the rule is as follows;

whats image to (whatimage +1)% 3

the problem is that when images are changing with this rule there is one moment it reaches 0, then as in tables no column 0 shows no image. Because the loop with that rule is (0,1,2,0,1,2,0,1,2 ......)

The question is, there a way that is (1,2,3,1,2,3,1,2,3,1,2,3)?


Thanks!!

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    edited February 2013
    //
  • SocksSocks London, UK.Member Posts: 12,822
    @Socks not found friend
    Cryptic !?


  • SocksSocks London, UK.Member Posts: 12,822
    what???
    Cryptic.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    Hi @RUPAS try this:

    Change attribute whatimage to (whatimage+1)%4
    Rule: When whatimage = 0
    Change attribute whatimage to 1

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

  • RUPASRUPAS Member Posts: 823
    this solution is not possible, because when 0 shows an image that contains no item. can look at the picture to understand I want to do
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2013
    this solution is not possible, because when 0 shows an image that contains no item. can look at the picture to understand I want to do
    Yes, I understood you're prob. first time, thanks. Have you tried my solution? It loops 1,2,3,1,2,3, etc; as you want (assuming whatimage starts at 0 though)... so... this solution is possible! (With your start image as number 3)

    Very nice looking image, btw...

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

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

    Here's my test file, for your interest (showing the loop, no images though):

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

  • beefy_clyrobeefy_clyro Member Posts: 5,394
  • RUPASRUPAS Member Posts: 823
    if I tried, it works well if you have 3 or more objects, which occurs when you have only 2? can not do the loop 1,2,1,2,1,2, always does 1,1,1,1.
  • RUPASRUPAS Member Posts: 823
    @beefy_clyro, @gyroscope is right, but it only works when you have more than 3 items
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2013

    The following works for me for looping 1,2,1,2, etc:

    Change attribute whatimage to (whatimage+1)%3
    Rule: When whatimage = 0
    Change attribute whatimage to 1

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

  • beefy_clyrobeefy_clyro Member Posts: 5,394
    Then change %4 to %3 and then you just get 1,2,1,2,1,2,1,2,1,2 ....
  • RUPASRUPAS Member Posts: 823
    yeah, I totally understand everything you say, but it seems that because of the language I can not explain very well. I'll try to make a video.
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2013

    Hi @RUPAS I was wondering, right from the beginning of your thread, why you're using a table at all when you have so few images....

    So you could try one of the following:

    Rule: When touch is pressed
    Change attribute whatimage to (whatimage+1)%4
    Rule: When whatimage = 0
    Change attribute whatimage to 1

    Rule: when whatimage = 1
    Change Image to yourimage1

    Rule: when whatimage = 2
    Change Image to yourimage2

    Rule: when whatimage = 3
    Change Image to yourimage3

    ----------

    Actually, if you're no longer using a table for this, could be simpler now, of course:

    Rule: When touch is pressed
    Change attribute whatimage to (whatimage+1)%3

    Rule: when whatimage = 0
    Change Image to yourimage1

    Rule: when whatimage = 1
    Change Image to yourimage2

    Rule: when whatimage = 2
    Change Image to yourimage3
    -----

    or:

    Rule: When touch is pressed
    Change attribute whatimage to (whatimage+1)%3
    Change Attribute: self.image to "MyPic"..whatimage

    -------

    or, without the modulus, of course:

    Rule: When touch is pressed
    Rule: When what image < 3 --- for 3 image loop
    Change attribute whatimage to whatimage+1
    Change Attribute: self.image to "MyPic"..whatimage
    Otherwise
    Change attribute whatimage to 1
    Change Attribute: self.image to "MyPic1"
    ------

    Then providing yourimage3 is the same as your start image, it'll loop nicely, without the use of a table. Just a thought.

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

  • RUPASRUPAS Member Posts: 823
    edited February 2013
    hi @gyroscope first thanks for your help, my game does not contain only 3 images, I have said as an example, my game is a point and click and have more than 15 items to collect, and I'm finding it difficult to create the inventory (which can be seen in image) the difficulty is I don't know the order in which a player will collect the items, and it is also difficult to make the code for when a player uses an item, the item must be removed to make room for another item. Understand now?

    @Digi-chain has a system like that I want to do, I have asked for help twice, but I never responded .... I would like him to help me
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2013
    hi @gyroscope first thanks for your help, my game does not contain only 3 images, I have said as an example, my game is a point and click and have more than 15 items to collect, and I'm finding it difficult to create the inventory (which can be seen in image) the difficulty is I don't know the order in which a player will collect the items, and it is also difficult to make the code for when a player uses an item, the item must be removed to make room for another item. Understand now?
    Yes, I do; it would have been helpful if you'd mentioned the word "inventory" at the beginning!

    Some of the straightforward rules I suggested can be utilized for an inventory system; I know, because one of my many games on the back burner is an adventure game, where I finished an inventory system with rules similar/including. (Here's a vid. for interest, although at this stage, the inventory system wasn't complete):


    @Digi-chain has a system like that I want to do, I have asked for help twice, but I never responded .... I would like him to help me
    OK. :-)

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

  • RUPASRUPAS Member Posts: 823
    @gyroscope haha sorry, it really ought to have that inventory, but thought you had seen in the picture I uploaded before. I want to do the entire inventory in one box, you have any idea how I could make it work well?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2013

    Just realised: I guess you're talking about the type of inventory system in @Digi-chain's excellent point-and-click game Spooky Manor, where a forward button is pressed, and the item image changes each time in another actor; if so, I'd approach it something like this:

    • Set up your table (I see it's best to have a table now if you're dealing with an inventory, and will make for easier adding and deleting items; rules not shown for that but I'm sure you're OK with that side of things). Make your column as Text, put in the names of your items. (Also make sure these correspond exactly with the image names of the items in the Library).

    • In your forward button (which can be amended for use in a back button, if required) put:

    Rule: When touch is pressed
    ----the following loop is outside of the change attribute for changing the name of the item, and doesn't use the modulus, because I couldn't get it to work using that method, i.e in the expression editor)---
    When Attribute MyItems < 5 (--- 5 in this case, being the max. amount of items in table list; change accordingly, of course)---
    Change Attribute LoopGo to true
    Change Attribute MyItems to MyItems + 1
    Otherwise
    Change Attribute MyItems to 1

    Rule: When touch is released
    Change Attribute LoopGo to false

    ----------

    • Now in the actor to show the inventory items as images:

    Rule: When LoopGo is true
    Change Attribute self.Image to tableCellValue(game.YourInventTable,scene.MyItems,1)

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

  • RUPASRUPAS Member Posts: 823
    @gyroscope Great, I've tried and the loop works perfectly, but I have been doubts, for example, in the table I have written all the items, but they can appear all because the player has not yet collected, then the order of appearance of the objects changes, like when a player has used an item I can not know which row is to delete it. know?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2013

    Hi again @RUPAS, I understand what you're saying...

    OK, this is it roughly: Firstly, if you have all your items in the table to start, but only some of them are visible to use, and then some more are added to be used, and others to be hidden when they've been used; in this case I would recommend a second column in the table, values as booleans. Those that can be used/seen will be true, those that can't will be false.

    This aspect then needs to be added into your rules for looping through just the true items, as well as for changing the item true or false accordingly, as and when. Also don't forget to change the total number of available items when these booleans are changed.

    -----

    A second way would be to just have only the amount of items that you start with in the table; then when an item needs to be added or deleted, you use the Add/Remove Row behaviour (as well as Change Table Value behaviour). Again, if you use this, don't forget to update the total amount of available items in the attribute (MyItems, in my example). I'm thinking that this way would be easier...

    I hope that's guided you in the right direction.

    PS Just a small correction to my example before: it's best that MyItems is a game attribute rather than a scene one... but I'm sure you caught that.

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

  • RUPASRUPAS Member Posts: 823
    @gyroscope Thanks again for your help, I understand all this is costing ..... what you say is correct as long as the player follows the order that I have marked to collect items, but my game is not so, for example, imagine that we are in the kitchen and have a spoon (item1) and fork (item2), if I pick first fork (add a row with the name item1) and then grab the spoon (I add a row item2), well, we are in row 1 fork and spoon in row 2, when the Use the spoon player I know I have to add a rule that says delete row 1. And when you use the holder also add a rule that says delete row 2, here is easy, but the problem is that I can not know if the player will first take a spoon or fork, then when the object is used I will not know that I have to delete row because I don't know if the fork is in row 1 or 2.
  • RUPASRUPAS Member Posts: 823
    @gyroscope Solved, thanks so very much for your help. Thanks!!
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited February 2013

    Glad I could help, @RUPAS :-) And best of luck getting your new game together; by that sneak peek, it's looking the business!

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

Sign In or Register to comment.