[Gelöst/Solved - LUA] Schieberätsel / Sliding Puzzle

  • #10, by afrlmeThursday, 13. November 2014, 22:43 10 years ago
    Here: http://wiki.visionaire-tracker.net/wiki/Sliding_Puzzle_(CMS).

    I'm still not 100% happy with it but whatever. It all works ok now but is not as global as I would like; in other words it's only good for the 1 puzzle.

    P.S: big thanks to Simon for debugging the script for me. There was some strange bug/error in which it wouldn't reset the tile positions after they had been moved with the startObjectTween function without reloading the scene. So Simon figured out that we should reset the positions with the startObjectTween as well. I was almost ready to pull my hair out as I knew what I had scripted should work.

    Imperator

    7278 Posts


  • #11, by cancel.logic.brainThursday, 13. November 2014, 23:25 10 years ago
    Hey AFRLme, thank you very much. That sliding puzzle looks nice (: Maybe I can use it.
    But I try to make one without coding...if I got good results, I'll upload it too.

    Newbie

    13 Posts

  • #12, by afrlmeThursday, 13. November 2014, 23:38 10 years ago
    Without coding? Ai sus! Sounds like a lot of work the me mate. Good luck! wink

    It's possible without code but it requires lot of work in the editor & lots of scene objects & conditions &/or values etc to control which object image should be displayed. That in itself sounds like a nightmare to me.

    Sliding Puzzles are quite complicated, then again I reckon most puzzles are complicated to make in the editor alone. Imagine how many conditions & images you would need for a memory game for example.

    Imperator

    7278 Posts

  • #13, by cancel.logic.brainThursday, 13. November 2014, 23:50 10 years ago
    grin Thx... I know, it's complicated. It's very easy to lose the overview^^ But I try (;

    You're right, most of it seems so simple.
    But again: Thank you very much for your upload. It saves my project grin

    Newbie

    13 Posts

  • #14, by afrlmeFriday, 14. November 2014, 15:54 10 years ago
    I've just updated the script & .ved file.

    I've made it a bit more customizable. Instead of triggering an image & condition through the script I've made it so that it calls a "called by other action" action that you add to the scene actions, which means you can specify what it should do yourself on puzzle solve by adding action parts &/or scripts to it. Instructions have also been updated.

    I know I've not gone into great detail with the instructions as they would be quite a lot of information if I were to cover the ins & outs of everything I did, from creating the puzzle pieces to finding the correct coordinates of where each tile should be placed etc (I'll give you a hint: I used lua script to automatically locate & print the coordinates to the log file).

    finding exact coordinates: create execute a script action part in at begin of scene action & include...
    for i = 1, 8 do
     local anim = ActiveAnimations["anim_p"..i].AnimationCurrentPosition
     print(i, anim.x, anim.y)
    end
    

    ...my tile animations were called "anim_p" with a prefix number attached to the end (1-9). So ..i added the loop number to the end of the name automatically. Nice & simple. smile

    Imperator

    7278 Posts

  • #15, by MachtnixFriday, 14. November 2014, 16:02 10 years ago
    Can I use the script in Visionaire beta 4?

    Thread Captain

    1097 Posts

  • #16, by afrlmeFriday, 14. November 2014, 16:07 10 years ago
    hmm...

    Not sure. Did we have startObjectTween or short-hand Lua available in 4.0 beta? Probably not. I think 4.0.1 is minimum version that can use this. But I recommend using it in 4.1 upwards.

    Imperator

    7278 Posts

  • #17, by MachtnixFriday, 14. November 2014, 16:12 10 years ago
    I try to start the mini game. Playing a 4.1-game-ved is mostly possible in 4.1, but not editing. But anyways I don't understand what you have done, so I never would change something... ;-)

    Machtnix

    Thread Captain

    1097 Posts

  • #18, by afrlmeFriday, 14. November 2014, 16:20 10 years ago
    Why are you still using 4.0 beta?

    Hell even I don't understand what I've done half the time. I just think about it, then write it.

    Imperator

    7278 Posts

  • #19, by MachtnixFriday, 14. November 2014, 16:30 10 years ago
    Because 4.1 doesn't work. We had this long discussion before... I don't want to repeat all. It's not your fault. grin

    I admire programmers (like you) who get another strange solutions than a "normal" thinking human being (like me)... I followed each single part of the puzzle. I think you change the part picture on every position (if I understand the script)? Two different ways: my: what a gamer plays in the real world. You: use strange logic... ;-)

    Thread Captain

    1097 Posts

  • #20, by afrlmeFriday, 14. November 2014, 17:44 10 years ago
    I use rational logic. It's everyone else that thinks illogically. I try to mentally break down how something should work (logic) & then I create based around that.

    The script slides the animation tile to the new position & swaps sliding tile name with target tile name. It also on tile (slot) click checks the move positions for the tile you clicked on by checking the index numbers we added to the move part of the table & if one of tables returns empty (nil) for the name then that means the tile can move to that slot. Pretty simple. Much easier than using millions of conditions, images & if queries to change the tiles.

    I was not very confident about being able to code this as I had nothing as a reference base & ended up having to piece together how it worked off the top of my head alone. I'm not very good at math or puzzles like this, so it was a bit of a challenge.

    & it could be my fault? I have terrible short term memory, so I probably read whatever you mentioned before but will have completely forgotten about it.

    Imperator

    7278 Posts