Results 1 to 20 of 26

Thread: Inventory

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Squire
    Join Date
    Sep 2009
    Location
    Colorado, USA
    Posts
    25

    Question Inventory

    -- Project: Continued from this post.
    To create a separate rpg-type graphical Inventory screen.

    --Progress:
    So far I've been able to place items in the world for the Player to "pick-up" by way of a "mouse right click" menu (though I haven't figured out yet why I need to double-click on that dialog menu to activate the choices) and then transfer these objects to players inventory using the basic example in the RPG World...

    My next step was to create a map called "Character Screen" and add the option in the player_menu.lua to go to the new map... which worked fine... EXCEPT:
    1. the original map scripts continue to run... which isn't good.
    2. Haven't figured out how to return to the original map when the Character Screen is "closed" without using a specific map name.

    I'm fairly certain I need to get back to the original map by way of finding the Player entity and then calling the map it's on... haven't completely figured it out yet though and any help on this would be appreciated.

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,377

    Default

    Right - here are ways to do that. First you need to get the player entity.

    Two ways - if you've set it using GetGameLogic:SetPlayer(playerEnt) at some earlier time (most of the examples do this), you can do this:

    Code:
    GetMapManager:SetActiveMapByName(GetPlayer:GetMap():GetName());
    Or, instead of using GetPlayer, you could do the same thing for ANY named Entity in any map (you should use SetName() on it first) in the game by doing:

    Code:
    ent = GetEntityByName("Player");
    
    then the next part is the same:
    
    GetMapManager:SetActiveMapByName(ent:GetMap():GetName());
    Note: I just thought of a problem.. you can't pause the game properly.

    I haven't exposed the C++ command "GetGameLogic()->SetGamePaused(true);" to script yet.

    If you set all your item/dialog entities with ent:SetPriorityLevel(C_PRIORITY_LEVEL_HIGH); this would cause them to continue running while the rest of the game is paused, if you could use the above SetPause() command.

    (otherwise some entities may continue to run in the game, well, if you put any on a watch list.. (so entities can chase people through doors, etc) )

    I'll add this in the next update... if you don't use watch lists, you really don't have entities running when the map is off the screen and you don't have to worry about it.
    Seth A. Robinson
    Robinson Technologies

  3. #3
    Squire
    Join Date
    Sep 2009
    Location
    Colorado, USA
    Posts
    25

    Default Inventory Screen and Game pausing

    Quote Originally Posted by Seth View Post
    Code:
    GetMapManager:SetActiveMapByName(GetPlayer:GetMap():GetName());
    --Worked... Thank you.
    Quote Originally Posted by Seth View Post
    Note: I just thought of a problem.. you can't pause the game properly.

    I haven't exposed the C++ command "GetGameLogic()->SetGamePaused(true);" to script yet.

    If you set all your item/dialog entities with ent:SetPriorityLevel(C_PRIORITY_LEVEL_HIGH); this would cause them to continue running while the rest of the game is paused, if you could use the above SetPause() command.

    (otherwise some entities may continue to run in the game, well, if you put any on a watch list.. (so entities can chase people through doors, etc) )

    I'll add this in the next update... if you don't use watch lists, you really don't have entities running when the map is off the screen and you don't have to worry about it.
    Yeah, in the your rpg example, the maid (assuming the Dad as well), continues running her goal script... the GamePaused would definately be useful.
    Until then, I'm going to try to maybe pause that by leaving/opening another dialog menu on the current map, at the same time as (or just before) the call is made to switch to the Character Screen Map. --Will work on that tonight. Though the real problem might be how to automatically close that new dialog when returning to player's map so that you don't return just to have to choose another option on a dialog menu...

    --Still studying and learning. Teaching an "old dog new tricks" not that easy.

  4. #4
    Squire
    Join Date
    Sep 2009
    Location
    Colorado, USA
    Posts
    25

    Default

    Quote Originally Posted by sirlich View Post
    ...Until then, I'm going to try to maybe pause that by leaving/opening another dialog menu on the current map, at the same time as (or just before) the call is made to switch to the Character Screen Map. --
    .
    Nevermind... seems dialogs will only be continued on the new map.. not on original map... hm.

  5. #5
    Squire
    Join Date
    Sep 2009
    Location
    Colorado, USA
    Posts
    25

    Default slightly off-topic: Mouse-over

    This is slightly off-topic and a deviation of my original project but, in a way, could be a necessary component to my Inventory screen. Mouse_overs...

    Using the script mouse_button.lua (in base) with m_bIsInsideRect and GetInputManager:GetMousePos() and slight modification, I've managed to get the description of user-activated objects on mouse-over. However, in order to get this, the script must be written into that particular entity's script...

    My intention would be for it to be global, so that it would'nt be necessary to rewrite it in every single entity script... for example: whenever the mouse is over ANY entity that is of a particular C_TYPE_ and to have that description in a small window...(the latter of which, I'm fairly certain, IS NOT possible with Novashell at present) instead of the plain dialog.

    I've tried binding the mouse and inserting the script into game_start.lua but it seems to just ignore it.

    Any suggestions?

    Edit: Another question pops up -- using the mouse position and "if (ent:GetName() != "") then" instead of "m_bIsInsideRect", is the same thing accomplished or does that actually require a "click"
    Last edited by sirlich; 10-11-2009 at 08:07 PM. Reason: Another question

  6. #6
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,377

    Default

    You can definitely do both of those things, it's just a question of how you want to.

    I'd probably be using an item database (like the one in the RPG example) , and "on-the-fly" spawning items and setting their data all using the same item script, that could be based on the button one.

    Using Entity:Data() you can set any amount of extra data in an entity on the fly, and the script can use that to grab the description, graphic, etc.

    To show items on mouse over without needing a click, you need to constantly be polling what is under the mouse and sending that item a message or something.

    Two ways to do that:

    1. Have each item script run a function every 100 MS that just the current mouse position and tests to see if it's under it

    2. Instead of above, make a special mouse script that does the same thing, that way, no matter how many items you have there is only one check per frame, so things won't slow down. If it sees an item under its position, it can send data to the item in question.

    This is some pretty advanced scripting stuff. In the mouse controlled RPG example, in the player script, there is code that shows how to convert a mouse coordinate into world coordinates and check to see what entities it is touching.
    Seth A. Robinson
    Robinson Technologies

Similar Threads

  1. Can't get into inventory screen
    By in forum Dink Smallwood HD
    Replies: 1
    Last Post: 08-25-2004, 11:22 PM

Bookmarks

Bookmarks

Posting Permissions

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