Locking Character Scaling at a Specific Point.

  • #10, by afrlmeSunday, 26. July 2015, 16:59 9 years ago
    What do you mean? You mean the size it would be if it wasn't being forced?

    Um there's the pointsize field, but I'm not sure how to access it or whether it would even be any use.

    I can think of a workaround though. Create a small npc character with transparent image files & have that follow the current character around the screen & you can check the scale value of that character instead seeing as it would be using the correct scale value.

    Imperator

    7278 Posts


  • #11, by DilatedSunday, 26. July 2015, 17:09 9 years ago
    Alright some context will probably make it easier to understand what I'm doing.

    The puzzle is that the character needs to reach something high up. So to get to that place you need to make your self big. However when you get to that object you keep getting smaller. To get around it you need to lock the characters size when he is large.

    This is done with the script you wrote

    local scale, char, state = 0, nil, false

    function beginFCS(c)
    if state == false then
    char = Characters[c]
    scale = char.CharacterSize
    char.Scale = false
    state = true
    end
    end

    function endFCS()
    state = false
    char.Scale = true
    end

    function loopFCS()
    if state == true then
    char.CharacterSize = scale
    end
    end

    registerEventHandler("mainLoop", "loopFCS")

    So whatever size at that point in time he is permanently like that (this works all good so far)

    However you are required to be greater than a certain size before you can reach the goal object.

    So if the character is bigger than [value] it activates the condition allowing you to pick up the object.

    Does that make sense?

    Forum Fan

    149 Posts

  • #12, by afrlmeSunday, 26. July 2015, 17:35 9 years ago
    Is the character allowed to move? or is it also locked in place? If the latter then might be an idea to use a NPC or even create the character as a scene object containing animations. But yeah I get the general gist of what you said.

    Ah wait, you are saying the players have to walk the character around & decide when to lock the character size manually, yes? In theory all they would have to do that is come as close as possible to the front of the screen as they can get no? Unless you've created something trippy in the way point values to have the character scale for the scene be all out of logical proportion.

    If you knew the scale at the interaction position, then couldn't you create the value manually & set another loop going to reduce the current character size by x until it reaches the actual scale value it would be at that position?

    If you want to find out the exact scale value at that position: go to the interaction point normally (without locking the scale) & then open up developer console (TAB) then type: exec print( game.CurrentCharacter.CharacterSize ), then press enter, then type PRINT LOG & look for the last message in the log which should contain a integer or float (decimal) value, which will be the characters scale at that point.

    Yes? No?

    Imperator

    7278 Posts

  • #13, by DilatedSunday, 26. July 2015, 17:56 9 years ago
    The concept is pretty wacked out so its probably easier to see exactly whats happening in this video haha (Place holder art) https://www.youtube.com/watch?v=TPopCOYAJkQ&feature=youtu.be

    Although primarily what I want it to do is that if paradigm is >[specific size] it activates the condition. And if it is any less than that, it disables that condition.

    I could probably set it up with an action area. So when the character enters the area where it makes him huge, it activates the condition.

    However it would be nice if it does it via script when paradigm is greater than certain size, this way it would be much more accurate and could be done in multiple spots in the room super easily. Rather than make multiple action areas. Which have potential to bug out.

    Forum Fan

    149 Posts

  • #14, by afrlmeSunday, 26. July 2015, 21:11 9 years ago
    I think any method used has the potential to bug out.

    The size that matters is the current character size yes? You could just query if character size more than equals or is equal to x then startAction(Actions["some_action"]) else start some other action end.

    I think you get the idea. You don't really need the condition at all.

    Imperator

    7278 Posts

  • #15, by DilatedMonday, 27. July 2015, 06:24 9 years ago
    Yeah, the character size is all I'm looking for, however the code we used before doesn't seem to react to the characters size on the screen.

    if game.CurrentCharacter.CharacterSize >= 100 then

    All this did was check the characters scale factor in its settings, not what its on screen.

    So I tried a few different things, but still only reacted the characters scale in settings, not how the character changes size on screen.

    Also doesn't need the condition? The main reason of this is to tell the character whether they can interact with the recycling bin or not.

    So if they are bigger than a certain size, it makes the condition true, allowing them to pick it up.

    If he is smaller, the condition is false and he just says "It is too high up"

    Unless this is a dumb way to do things haha?

    Forum Fan

    149 Posts

  • #16, by afrlmeMonday, 27. July 2015, 14:03 9 years ago
    No I was just pointing out that you could create the query & action entirely in Lua script without needing to use the condition. Sure the condition is also an acceptable method. Actually there's not really a wrong method unless said method doesn't work! wink

    The CharacterSize field is the current size of the character.

    Could you please post for me the full script in a code block & also some screenshots of the action parts / action blocks please?

    Imperator

    7278 Posts

  • #17, by DilatedMonday, 27. July 2015, 14:19 9 years ago
    local scale, char, state = 0, nil, false
    
    function beginFCS(c)
     if state == false then
      char = Characters[c]
      scale = char.CharacterSize
      char.Scale = false
      state = true
     end
    end
    
    function endFCS()
     state = false
     char.Scale = true
    end
    
    function loopFCS()
     if state == true then
      char.CharacterSize = scale
     end
    end
    
    registerEventHandler("mainLoop", "loopFCS")
    
    


    beginFCS("Paradigm") -- set character as Tom, with current scale value of Tom.
    
    



    endFCS()
    


    This is the code I'm using to trigger the condition, all it needs is the If to react to the characters size on screen.

     if game.CurrentCharacter.CharacterSize >= 101 then
     Conditions["Paradigm_Big_activated"].ConditionValue = true
    end
    


     if char.CharacterSize <= 100 then
     Conditions["Paradigm_Big_activated"].ConditionValue = false
    end
    
    


    also a screenshot just in case

    http://i.imgur.com/mpl3ZSr.png

    Is this enough?

    Forum Fan

    149 Posts

  • #18, by afrlmeMonday, 27. July 2015, 18:34 9 years ago
    Hmm...

    1. I could probably revise the script. I don't remember the reason why I didn't make it so that the loop could be unregistered. But whatever, it's still valid.

    2. How & when exactly are you checking the CharacterSize values? I suggest creating an execute a script action part at the top of your action list for the interaction, containing...
    if game.CurrentCharacter.CharacterSize > 100 then
     Conditions["Paradigm_Big_activated"].ConditionValue = true
    else
     Conditions["Paradigm_Big_activated"].ConditionValue = false
    end
    

    then add a pause action part for say 100 to 250ms or whatever.

    3. You need to close off the if query in your interaction action block with an end if action part.

    4. Not all scripts have to be written or added to the script section of your project. Most of the time, the execute a script action will suffice, especially for single use scripts & for calling functions. Also not everything has to be stored in variables. Actually scripts will run much faster when you don't bother using variables, but it's only a minute difference in loading time, so it doesn't matter all that much.

    5. local just makes it so that a variable, table of function is only accessible from the specific script or function that it is declared inside of.

    Imperator

    7278 Posts

  • #19, by DilatedTuesday, 28. July 2015, 03:55 9 years ago
    Awesome I (you) got it working! grin Thanks.

    So what fixed this, Executing the script on the actual object.

    However it didn't work at first. What it would do is the first time you interact with the object it would not work, then the second time it would? Weird. So then I extended the pause to see if the script was just taking its sweet time. Nope, still the same thing. Then I added a 1 ms pause BEFORE the script execution. Then it works everytime. How does that even make any sense hahah.

    Anyway lifesaver as always Lee, thanks!

    Forum Fan

    149 Posts

  • #20, by afrlmeTuesday, 28. July 2015, 11:29 9 years ago
    1ms pause won't actually be 1ms. The system loops approx every 16ms to make up 60fps. & I don't know why it should need a pause before - strange. very strange! grin

    Imperator

    7278 Posts