About items

  • #20, by afrlmeMonday, 27. November 2017, 14:18 7 years ago
    The reason you specified is why I dislike the dragged item system. The images are the same size as in your inventory & the interaction position that detects when a scene object, character or item is below the cursor image is in the center of the image sprite rather than the top left.

    I highly recommend using a command based inventory system.

    1. create a custom cursor for each command & inventory item. This way you can have both an active & inactive image/animation for each command & held item that's also different from the image of the inventory item.

    2. create all of your commands inside of a single interface. This includes both general commands (use, take, examine, walk to, etc) & also a command for each & every single inventory item. It's a lot of work sure, but it's worth it in the end.

    3. inside of the command properties tab for each of the command buttons types you have just created, assign a cursor & set the "command can be used on" option to objects & characters. This is so that the cursor will automatically be set to the relevant cursor each time you change to a new command. Saves a lot of time in the long run. The other option is so that you can use the command on both objects (scene objects, items) & characters.

    4. Now go to the items tab & create all of your items if you haven't already done so, assign an image or animation (animation if you want to hide the image when the player is holding the item in hand) to each one. Now inside of the actions tab for each item create an executed command (immediate) take/use (or whatever command you want it to be for setting the item to hand) & now create an action part to change the current command to that of the relevant item command. In-game it should now change to that command & show the custom item cursor you created.

    5. Inside of actions tab for scene objects/characters you can now create execute command (at destination) which you can set as one of the item commands you have created.

    I admit it probably sounds a bit complicated with text only, but I highly recommend using this method as it allows you to customize easily & looks great.

    In regards to hiding the image in the inventory, you could create a 2 frame animation for each item. The first frame would contain the item image, the second frame should be a transparent image with the same size canvas as the frame with the item image. What you would need to do is edit each frame to open up the edit dialog window & then you would create some custom actions for each frame. In the first frame you would create an execute a script action part & then you should add something along the lines of this to it...
    if game.CurrentCommand:getName() == "carrot" then
     ActiveAnimations["itm_carrot"].AnimationFirstFrame = 2
     ActiveAnimations["itm_carrot"].AnimationLastFrame = 2
    else
     ActiveAnimations["itm_carrot"].AnimationFirstFrame = 1
     ActiveAnimations["itm_carrot"].AnimationLastFrame = 1
    end

    Obviously you will need to replace carrot with the actual name of the relevant command & itm_carrot with the name of the item whose frames you are currently editing. Quick note: names are case sensitive.

    For the second frame you would do the exact same thing except you will change the script slightly so that it forces the frame back to frame 1.
    if game.CurrentCommand:getName() == "carrot" then
     ActiveAnimations["itm_carrot"].AnimationFirstFrame = 1
     ActiveAnimations["itm_carrot"].AnimationLastFrame = 1
    else
     ActiveAnimations["itm_carrot"].AnimationFirstFrame = 2
     ActiveAnimations["itm_carrot"].AnimationLastFrame = 2
    end

    Anyway, hopefully this massive wall of horrible text will be of some help to you. Normally, I'd share some screenshots, but I have nothing at hand at the minute. Though I've posted images in the past of how I setup a command based inventory system. They are floating about on the forum somewhere.

    P.S: I recommend using Lua script for the command cycle interface. Would make much less work, however you mentioned that you have no clue how to script with Lua. Instead what you could do when you take an item from the inventory is set a condition to true then when you drop the item set the condition back to false. In the global right mouse button actions you need to wrap all of the action parts inside of an if query that checks if an item is held or not. So that on right click you either cycle through the commands or you drop the current item instead & change back to the default command.

    Imperator

    7278 Posts


  • #21, by JorkzMonday, 27. November 2017, 16:15 7 years ago
    Thank you very much !!

    I've already try all the first points of your reply.
    Until the part 5. The frames trick is exactly what I want !

    But the item is flashing in my inventory...
    Perhaps the script isn't correct, unless I don't understand this sentence
    then you would create some custom actions for each frame. In the first frame you would create an execute a script action part & then you should add something along the lines of this to it...

    Newbie

    90 Posts

  • #22, by afrlmeMonday, 27. November 2017, 16:51 7 years ago
    Yeah, you're using the wrong name. It's the actual item object name in the items list that you need to use.

    https://i.gyazo.com/b26e12daeb03c905f5ba60558462056c.png

    P.S: I messed up the script a little bit too. I wrote it off the top of my head. Replace all instances of CurrentCommand with ActiveCommand. My bad, sorry.

    Imperator

    7278 Posts

  • #23, by JorkzMonday, 27. November 2017, 17:03 7 years ago
    Yes I changed that but it still not working.
    Perhaps is it the command's name ?
    Please where can I find this ?

    Newbie

    90 Posts

  • #24, by JorkzMonday, 27. November 2017, 17:13 7 years ago
    Ok...
    Thanks !!!

    It's working smile smile smile but apparently we have to replace it just for the first frame.

    Now I will test this
    I recommend using Lua script for the command cycle interface. Would make much less work, however you mentioned that you have no clue how to script with Lua. Instead what you could do when you take an item from the inventory is set a condition to true then when you drop the item set the condition back to false. In the global right mouse button actions you need to wrap all of the action parts inside of an if query that checks if an item is held or not. So that on right click you either cycle through the commands or you drop the current item instead & change back to the default command.

    Newbie

    90 Posts

  • #25, by afrlmeMonday, 27. November 2017, 17:25 7 years ago
    The command name is the name of the button. In my example below, I called an item command 101_rock.

    https://i.gyazo.com/8cba7881e95bc506edc7c0b250352a11.png

    https://i.gyazo.com/2e37faa187a44ff9132f9e55b50c3343.png

    As you can see I've actually used the same name for both the command & the item, but that's not really important. I recently switched over to a naming convention where I prefix the scene & chapter number to animations & items so that I know what belongs to what. 101 in my case equals chapter 1 scene 01.

    Quick note: you might want to increase the default delay of the animation from 20ms to something a little bit higher, maybe to something around 100ms or so.

    Imperator

    7278 Posts

  • #26, by JorkzMonday, 27. November 2017, 17:42 7 years ago
    Ouch.
    I spoke too fast...
    It's better... but not very stable...
    Because the tansparent frame still exist, it takes time to disappear. It's not a problem when I'm out the interface... But in the interface itself, with a right click (or a left click on the initial place ) the key cursor disapear too, and the transparent frame is staying. :/

    Is it an animation's delay problem ?

    Newbie

    90 Posts

  • #27, by sebastianMonday, 27. November 2017, 17:55 7 years ago
    wasn't there a native solution in the engine for command cycling? 

    Thread Captain

    2346 Posts

  • #28, by JorkzMonday, 27. November 2017, 18:00 7 years ago
    ...And when the key cursor is on the closed inventory's button; if I left click on this button. The item in the open inventory is flashing  while a little msecond.

    I will stop there for today. I'm sorry for all these noob's questions !!


    Newbie

    90 Posts

  • #29, by JorkzMonday, 27. November 2017, 18:26 7 years ago
    wasn't there a native solution in the engine for command cycling?
    I'm not sure I understand this question. What is "native" ?  What do yo mean by "there", what is it about ? :/


    Newbie

    90 Posts

  • #30, by afrlmeMonday, 27. November 2017, 21:27 7 years ago
    He's talking about the next command option in the set command action part, but it's only a valid solution if you only create typical use, take, examine, walk to commands because it cycles through all available commands.

    Yeah there will be a delay because of the 100ms you set. You can set to 20ms if you prefer, but it might mess up due to the script not executing fast enough. This is why I'd much rather Simon removed the static image option for items & replace it with active animation & inactive animation instead.

    Imperator

    7278 Posts