1. #1
    New Member Follow User Gallery
    Join Date
    Dec 2018
    Posts
    12

    Default MemWrite/Read MouseVPos

    Hey guys Happy New year)
    Basic question about memblocks, I think it was asked before but I can't find it.

    I need one macro to get current Mouse V Pos and store it in a memblock and the second one to read that Mouse V Pos value.
    I tried MemRead and MemWrite, but I get wrong values, at least they don't always equal to [MouseVPos]
    Is there somewhere a simple example how to MemRead and MemWrite such values as MouseVPos?

  2. #2
    New Member Follow User Gallery
    Join Date
    Dec 2018
    Posts
    12

    Default

    It seems this works for my task:
    [IButton, ???, "",

    [VarSet, mv, [MouseVPos]]
    [VarDef, read_from_mem, -1]

    [MemCreate, mv_mem, 5, 0]
    [MemWrite, mv_mem, mv,,4]

    [MemRead, mv_mem, read_from_mem,,4]

    [Note, mv] // current mouse v pos
    [Note, read_from_mem] // mouse v pos from mem

    ]



    Is it ok to write this way?

    Still don't quite understand why doesn't work for example
    [MemWrite, mv_mem, mv,,3]

    ...
    [MemRead, mv_mem, read_from_mem,,3]
    Last edited by me2beats; 01-01-19 at 11:04 PM. Reason: trying to [CODE]

  3. #3
    Moderator Follow User Gallery
    Join Date
    Jun 2004
    Location
    UK
    Posts
    11,462

    Default

    Yes, it looks as though MemWrite is broken for some data formats.

    Float is the standard format used by zscript variables and that will work OK. But I generally use MVarDef, MVarSet and MVarGet when I need memory blocks in zscript as they are simpler to use.



    [MemDelete, mv_mem]//just getting rid of previous mem block

    [VarSet, mv, [MouseVPos]]
    [MVarDef, mv_mem, 1, 0]
    [MVarSet,mv_mem,0,[MouseVPos]]

    [Note, mv] // current mouse v pos
    [Note, [MVarGet,mv_mem,0]]// mouse v pos from mem

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •