Results 1 to 4 of 4

Thread: Script to change SNAP points based on side of object.

  1. #1

    Script to change SNAP points based on side of object.

    This is kind of a cross post form SUGGESTIONS, but there was no replies so thought I would try again in here...

    [url=http://www.berserk-games.com/forums/showthread.php?3780-Makew-manual-snap-points-only-work-on-the-side-they-are-applied]Original Post[/url] @ Suggestions
    Quote Originally Posted by Tragic View Post
    There is a problem with manual snaps points..... basically if you have a complex double sided tile and wish to use snaps, you can add them, but even though the snaps understand what side they are applied to, the snap is active right through the object. So all the snaps put on side A will still snap objects if side A is on he table and side B is visible... this not only makes snaps kinda pointless in this situation, but also you get all these active snaps that are in the wrong place for the face up tile

    Basically we need a fix that makes snaps only function on the faces that they are applied. Or maybe a new snap type that dose this, like a blue dot, instead of the regular green.

    Quote Originally Posted by Mark View Post
    I made a scripted solution for you. Paste this code into whatever object.

    How it works:
    • Write a name or description when the object is flipped face up.
    • Flip it face down.
    • The object's name and description will disappear, showing as empty fields.
    • Flip it back up.
    • The object's name and description will re-appear as it was.


    This works even through undoing and will work if you save it face-down, reload it and flip it back up.

    Code:
    myName = ""
    myDescription = ""
    lastFaceDown = nil
    
    function onSave()
        local stuffToSave = {}
        stuffToSave.name = myName
        stuffToSave.desc = myDescription
        stuffToSave.lastFaceDown = lastFaceDown
        
        return JSON.encode(stuffToSave)
    end
    
    function onLoad(save_stuff)
        if save_stuff ~= "" then
            --RECOVER SAVE INFORMATION.
            local stuffToSave = JSON.decode(save_stuff)
            myName = stuffToSave.name
            myDescription = stuffToSave.desc
        else
            myName = self:getName()
            myDescription = self:getDescription()
        end
        local rot = self:getRotation()
        lastFaceDown = rot.z > 90 and rot.z < 270
    end
    
    function onCollisionEnter()
        local rot = self:getRotation()
        local faceDown = rot.z > 90 and rot.z < 270
        
        if faceDown == true and lastFaceDown == false then
            lastFaceDown = true
            --SAVE NAME/DESC AND THEN HIDE IT.
            myName = self:getName()
            myDescription = self:getDescription()
            self:setName("")
            self:setDescription("")
        elseif faceDown == false and lastFaceDown == true then
            lastFaceDown = false
            --SET TO SAVED NAME/DESC.
            self:setName(myName)
            self:setDescription(myDescription)
        end
    end
    Mark once gave me some cool code to help with chit tooltips... could this be modified to change snap positions depending on the face?
    Basically is there a way I could modify this script to "change" the snap points on an object based on what side it was on?

  2. #2
    No you can't really manipulate Snap points with scripts. other than removing them by removing the object there attached to.


    Why not just turn your tokens into states and do away with flipping them ?

    Each state shows a different face up and each state has its own snap points.

  3. #3
    You could make a script to change the object's state when it's flipped over. I think snap points are conserved here. Or just have no script and change whatever mechanic you're using to use states instead of flipping.

  4. #4
    Quote Originally Posted by Mark View Post
    You could make a script to change the object's state when it's flipped over. I think snap points are conserved here.
    Its a little more work what with using Scripting to change states on flip, But this is a great idea if you don't wont to confuse people by replacing the "Flip" with a select state command.

    This is probably the best go to solution with the current tool set we have.

Similar Threads

  1. Replies: 0
    Last Post: 04-02-2017, 05:24 PM
  2. A few issues with snap points
    By Sancho in forum Bug Reports
    Replies: 2
    Last Post: 01-14-2017, 09:36 PM
  3. Snap points for dice
    By figment3 in forum General Discussion
    Replies: 5
    Last Post: 11-28-2016, 05:01 AM
  4. [SOLVED] Need Help With Snap Points
    By Kuolema in forum General Discussion
    Replies: 4
    Last Post: 04-20-2016, 10:01 AM
  5. Expanding on Snap points
    By Unreal_Ed in forum Suggestions
    Replies: 4
    Last Post: 07-05-2015, 04:35 AM

Posting Permissions

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