Move object to absolute position with Lua.

  • #20, by MachtnixSunday, 06. December 2015, 03:50 9 years ago
    I only want target coordinates the character could jump to. It doesn't matter if it's a absolute position or something else. If the player clicks on one of the field pipes I want to save
    1. the object the character is docking at (in my way it's only a zero object). that means one value (especially his name or ID)
    or
    2. the fixed position this object has. That means two values (x, y).

    Both cases are ok. But I didn't find a Vis procedure or a function which give me this coordinates by click. Maybe I have to create 25 action areas or I have to check the mouse position on every field to compare with the object below. I only want to put the values into a variable to exchange with another pipe modul from stack. Ke4's script is alright and well, but I haven't no position. So the mini game is blocked at the first step...

    Machtnix

    Thread Captain

    1097 Posts


  • #21, by ke4Sunday, 06. December 2015, 12:18 9 years ago
    I'm not sure what you are intended to do, but you can get the cursour position by this Vis function if you need it.

    getCursorPos()
    


    http://wiki.visionaire-tracker.net/wiki/GetCursorPos

    Key Killer

    810 Posts

  • #22, by afrlmeSunday, 06. December 2015, 13:15 9 years ago
    I'm not sure what you are intended to do, but you can get the cursour position by this Vis function if you need it.

    getCursorPos()
    


    http://wiki.visionaire-tracker.net/wiki/GetCursorPos


    That only returns the cursor position based on current viewport (part of screen that is shown)

    The actual position on scene in general is done by adding the scrollposition values to both x & y...
    local x = (getCursorPos().x + game.ScrollPosition.x)
    local y = (getCursorPos().y + game.ScrollPosition.y)
    
    print(x, y)
    


    @ Machtnix: I don't understand what you are saying / asking. Could you provide some screenshots or a diagram or something to help explain what you are wanting to do?

    Imperator

    7278 Posts

  • #23, by MachtnixSunday, 06. December 2015, 22:30 9 years ago
    Btw: I hate it to log in every time the connection was disconnected for a little while... :-( This "keep logged in" button doesn't work here.


    @ Machtnix: I don't understand what you are saying / asking. Could you provide some screenshots or a diagram or something to help explain what you are wanting to do?

    OK. It's hard to me to explain a complicated problem in English I not even describe well in German... ;-) You see the screenshot. The player starts the game and there are 25 closed fields and an open stack (No. 26) which is the "parking place". After one mouse click every cover will be open and the player finds a piece of pipe hidden before. That works. After the second click the pipe will be exchanged with the stack. So thats the given situation now after opening some covers.

    To connect the pipes before the liquid reaches the pipe the player has to change No 1 with the stack No 26. Its - fortunally - the right one he need, but mostly the player has to change a lot in and out to get the right jigsaw into the right slot. In this case he want to go down with Pipe No 26. Of course he could change No 6 with 26 and then with No 1 to build a straight pipeline. Both is possible.

    On the stack object are three variables with the values of the ID of the jigsaw which is laying on, the old position - that's the object name the character is set to - where the jigsaw was laying before and an empty "parking" variable. You know? x=y, y=z, z=x.

    The player clicks on No 1. Now I must read out and save the assigned object of No 1 and the ID of the jigsaw there (it's absolutely No 12, maybe). After clicking the No 1 jumps to No 26 and vice versa. I need the object's name to give the target to No 26 it has to jump to. He don't know the way, don't he? I prefer object names instead of absolute positions, I only need ONE value. As a game developer you can fill in this object, but I don't know the script data structure of Vis which can do the same.

    After exchanging the three values will be overwritten with the new datas: there are object's name No 1 and jigsaw ID No 12 on the stack now.

    OK, maybe the player wants to connect the pipe now with No 8 (the standing one). He clicks on No 8 and I need to get two values like before: the object (No 8) and the ID (this pipe may have the ID 4 - it depends how I have sorted the pieces on the scene. I need the IDs later to check the correct closed connection). No 8 jumps to No 26 and vice versa. On position No 8 is ID No 12 now (you remember?). Then the script overwrite the stack variables.... and so on.

    Of course I can look after the mouse position and get the object's name which is down under. But it seems very complicated to me. I only need the name of the object all jigsaws are "docked on". In the Vis editor it's the object to which the character is assigned. There are two actions: "set to object" and "walk to object". That works. I have 49 objects (to explain why 49 is too much now...). There are arranged in a raster. That's all.

    I need something like this - on mouseclick:
    Value x = getNameofAssignObject ()
    Value y = getNameofCharcter ()

    So I tried some which looks similar to that but I can't see if it works or not... sometimes the Vis player is frozen... so that wasn't all right. I don't know anything about Visionaire inside...

    Machtnix

    http://abload.de/img/tutorialahlzj.jpg

    Thread Captain

    1097 Posts

  • #24, by afrlmeSunday, 06. December 2015, 22:47 9 years ago
    Why not just use an animation for each tile. You can force the current frame shown via Lua script. Each animation would contain the pipe images in the same order. So you would need to check the current tile, the current animation index to calculate the next tiles direction, to get the next tile.

    This is quite a complicated puzzle to create. I dare say it's probably more complicated than a sliding puzzle because you have multiple paths & outcomes. It will use a grid though the same as a sliding puzzle.

    Can you rotate the tiles too? If so, then it will be even more complicated.

    From what I can tell from your screenshot, you have 2 tile types. Straight & curved. So I guess you would need 2 animation frames for that & 4 rotation degrees, 0, 90, 180 & 360. So that means you need to check the current tile, the animation index & the rotation value, then you need to check if there is another tile to the side of it & what that tiles animation index & rotation value is.

    Imperator

    7278 Posts

  • #25, by MachtnixSunday, 06. December 2015, 23:16 9 years ago
    I haven't rotation (I described before). I have six types of tile, yes: two straight and four curved. I filled all 26 tile ID in this six groups to check the connection afterwards.

    I haven't understand your animation solution right yet. I looked for the animation index (sounds helpful) but I haven't an idea how it works. I tried some numbers from 0 to 10...
    It sounds more economical to have only six animations for each place. OK, if I don't want to see the exchange, I can use it.

    It doesn't matter if the tiles will be exchange REALLY or not. That means: one click and the exchange is done. But I prefer a slower and visible flight to show the player what happens. The short one is of course the easier one.

    I tried it before. You need only a storehouse object with 19 animations. Six stills for the pipes itself, two fluid animations each and one top picture, right? I found big problems this way to detect the four boolean openings to check the connection, so I rejected it. Maybe there is a simple Lua way.

    But how can I get the animations from each?

    Btw: I started with Vis GUI only first. All constructions are very sensible and made for an editor solution... After a while I detected: it's not working without Lua. Shit!

    Yes, it's more complicated I believed before. So, thats experience, isn't it? I have to learn "graph theory" to solve it simple... ;-)

    Machnix

    Thread Captain

    1097 Posts

  • #26, by afrlmeSunday, 06. December 2015, 23:40 9 years ago
    Aye I think it is complicated. I only know how I would probably go about creating this puzzle but it would be mostly using Lua script & a grid system.

    The grid would be a table that contains the index values from 1 to 25 (based on the image you attached) & for each tile we would add a value or string name to it. So each time we clicked on a tile we could update the value associated with said tile. Once the liquid reaches a tile you would then use the value associated with that tile to check if it is empty or which pipe type is used & then check the grid to find out if there are any more tiles available in the direction it is going or whether you have reached the target & so on.

    Even without the rotation it's still complicated because you have multiple pipes & a lot of tile slots.

    P.S: sorry. I didn't manage to read through your entire post, which is why I didn't know about rotation or not. I just skimmed through it to get a basic understanding of what you were wanting to do. Actually the attachment was mostly what I based my last message on.

    Imperator

    7278 Posts

  • #27, by MachtnixMonday, 07. December 2015, 00:10 9 years ago
    P.S: sorry. I didn't manage to read through your entire post, which is why I didn't know about rotation or not. I just skimmed through it to get a basic understanding of what you were wanting to do. Actually the attachment was mostly what I based my last message on.

    This thread has been started by another user, so that's ok. Sometimes I don't know for myself what I had written or not...

    As I started the mini game I said: "that looks simple, I'm ready in... three days... I have to do this and this and this and that's it! Pah! ;-)

    But after weeks suddenly I have more than five HUGE problems I haven't not yet any solution for. The first starts with the shuffle placement of 26 tiles. Yeah, there is a random function in Vis. I can say: "generate a random number between 1 and 26". Right? But then the difficulties started again. After days the result was a construction with recursive loops, many if-clauses, something like that. Too much Lua.

    Short: I did it without shuffle. I made 10 tables with 26 shuffled numbers and on every game it starts with another one. Quick and dirty. Of course it's a true repeat, a fake.

    I have been thinking about your "table solution" and I think it's the best one for scripters with a lot of advantages Not for me.

    Machtnix

    Thread Captain

    1097 Posts

  • #28, by MachtnixTuesday, 08. December 2015, 18:25 9 years ago
    OK. Das Projekt ist gestorben. Seit zwei Wochen versuche ich nun, einen simplen Wert durch Anklicken abzufragen, um mit diesem Wert die neue Position anzusteuern bzw. die Animationen auszutauschen. Anscheinend weiß auch niemand, wie das geht.
    Ohne die Möglichkeit, die unterschiedlichen Werte in eine Variable einzusetzen und nur diese abzufragen, müsste ich 150 If-Anfragen bei jedem Klick starten (jedes Feld einzeln nach allen sechs Möglichkeiten abfragen), was ich natürlich nicht mache.
    Offensichtlich ist das Erstellen eines Minispiels ohne Programmierung nicht möglich. Und NUR Programmieren hatte ich auch nicht vor.

    Machtnix

    Thread Captain

    1097 Posts

  • #29, by afrlmeTuesday, 08. December 2015, 21:00 9 years ago
    Not a case of not knowing how. It's a case of it would take ages & I doubt anyone would be willing to sort it out for free. It's a very complicated puzzle, especially when considered from the developers / programmers perspective because it requires a lot of conditions, values & if queries whether you sort it out in the editor, with script or a mixture of the two.

    The sliding tile puzzle took me hours to create & to figure out the logic behind it. Math is not my strong suit. I hate it. & I somehow think this pipe puzzle is going to be even more complicated to get working 100% bug free & A-Ok.

    I wouldn't say it's not possible, because it clearly is as other people have already made existing puzzles. I know that personally, I myself would be able to figure it out but I have neither the time nor inclination to do so.

    The only two things I can tell you is that a grid consisting of a table would be the way to go & that scripting would be by far the fastest method of creating the puzzle. Doing this entirely in the editor would be a right chore. confuse

    Imperator

    7278 Posts

  • #30, by MachtnixWednesday, 09. December 2015, 16:59 9 years ago
    Yes, it's a complicated one. I know this before. But it's annoying that it isn't usable with editor tools only. So I have to learn a script language AND try to explain this in English too (I hoped here will be a German community).

    That's no longer working with Visionaire - it's programming. I could do this with a piece a paper and a pencil, doesn't matter. If I have to learn a language to solve this - why shouldn't I learn Python or C++ or Actionscript rather? It's a test for Visionaire itself. Vis is very nice to make a game with a character walking through some scenes to pick up items and talk to some other persons. Visionaire is a very fine tool for that. But at the moment you want a little bit more you have to pan to Lua. This is my 4th mini game I tried. No one of them works at last.

    I tried this editor action "go to action part". It seems like old BASIC with "goto line 22". Yes, I can do loops with them. But is it practical...? Second: I didn't found an option to insert values into iterable objects to count them and use them as a free variable parameter, that's necessary to handle 26 equal tiles with one called function for all...

    Machtnix

    Thread Captain

    1097 Posts