The Inventory: Making static?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

The Inventory: Making static?

James C. Wilson
This probably has a very simple answer, but after wading through the standard inventory I've yet to find it:
How do I make the inventory, when opening, simply pop into place, without using a sliding transition as it currently does?
 
Thanks,
  James
Reply | Threaded
Open this post in threaded view
|

Re: The Inventory: Making static?

cwalther
Administrator
James C. Wilson wrote:
> This probably has a very simple answer, but after wading through the standard inventory I've yet to find it:
> How do I make the inventory, when opening, simply pop into place, without using a sliding transition as it currently does?

Adjust or remove the last argument of moveto(), that's the animation duration, in

  pipmak.thisnode():moveto(0.5, 1, -width/2, isshown and -56 or -1, 0.25)

(http://pipmak.svn.sourceforge.net/viewvc/pipmak/trunk/demo/Demo.pipmak/50/node.lua?revision=231&view=markup#l42 )

 -Christian

Reply | Threaded
Open this post in threaded view
|

Re: The Inventory

James C. Wilson
Thanks very much. By the way, I'm having a bit of trouble applying the inventory operations in the demo to my project: Is this the proper way to test if an inventory object is carried, then drop it?
Pipmak doesn't see equality.

hotspot {
        cursor = cur_inventory, enabled = not state.observCablePlaced,
    onmousedown = function()
            if state.inventory[state.inventory.carried] == "TVCable" then
               inventory:message("drop", "TVCable")
               pipmak.gethotspot(3):enable(false)
               state.observCablePlaced = true
               pipmak.getpatch(1):setvisible(true)
            end
        end
}


Thanks,
  James


From: Christian Walther <[hidden email]>
To: James C. Wilson <[hidden email]>; Content creation for the Pipmak Game Engine <[hidden email]>
Sent: Wednesday, December 21, 2011 4:59 PM
Subject: Re: The Inventory: Making static?

James C. Wilson wrote:
> This probably has a very simple answer, but after wading through the standard inventory I've yet to find it:
> How do I make the inventory, when opening, simply pop into place, without using a sliding transition as it currently does?

Adjust or remove the last argument of moveto(), that's the animation duration, in

  pipmak.thisnode():moveto(0.5, 1, -width/2, isshown and -56 or -1, 0.25)

(http://pipmak.svn.sourceforge.net/viewvc/pipmak/trunk/demo/Demo.pipmak/50/node.lua?revision=231&view=markup#l42 )

-Christian

Reply | Threaded
Open this post in threaded view
|

Re: The Inventory

cwalther
Administrator
James C. Wilson wrote:

> I'm having a bit of trouble applying the
> inventory operations in the demo to my project: Is this the proper way
> to test if an inventory object is carried, then drop it?
> Pipmak doesn't see equality.
>
> hotspot {
> cursor = cur_inventory, enabled = not state.observCablePlaced,
> onmousedown = function()
> if state.inventory[state.inventory.carried] == "TVCable" then
> inventory:message("drop", "TVCable")
> pipmak.gethotspot(3):enable(false)
> state.observCablePlaced = true
> pipmak.getpatch(1):setvisible(true)
> end
> end
> }

One mistake I can see is that the "drop" message of the inventory takes
an index, not an object name. You can also leave out the argument
entirely, it will then automatically assume state.inventory.carried. See
nodes 9 (use of the key from the inventory in a similar way to what
you're trying to do) and 50 (inventory) in the demo project.

If as you say you don't even get that far because
state.inventory[state.inventory.carried] == "TVCable" is never true,
then I would suggest inserting
pipmak.print(state.inventory[state.inventory.carried])
or examining state.inventory using the table inspector from the Lua
command line to find out what it is.

  -Christian



Reply | Threaded
Open this post in threaded view
|

Re: The Inventory

James C. Wilson
Okay, thanks..It looks like taking away the unnesseary arguement solves it. However, for the future, I'm not aware of what the list index of the object is, or how to find it. If it's the number that the inventory table assigns the object, wouldn't that be biased toward the order in which the player picks up items?


From: Christian Walther <[hidden email]>
To: [hidden email]
Sent: Tuesday, January 3, 2012 11:55 AM
Subject: Re: The Inventory

James C. Wilson wrote:

> I'm having a bit of trouble applying the
> inventory operations in the demo to my project: Is this the proper way
> to test if an inventory object is carried, then drop it?
> Pipmak doesn't see equality.
>
> hotspot {
> cursor = cur_inventory, enabled = not state.observCablePlaced,
> onmousedown = function()
> if state.inventory[state.inventory.carried] == "TVCable" then
> inventory:message("drop", "TVCable")
> pipmak.gethotspot(3):enable(false)
> state.observCablePlaced = true
> pipmak.getpatch(1):setvisible(true)
> end
> end
> }

One mistake I can see is that the "drop" message of the inventory takes
an index, not an object name. You can also leave out the argument
entirely, it will then automatically assume state.inventory.carried. See
nodes 9 (use of the key from the inventory in a similar way to what
you're trying to do) and 50 (inventory) in the demo project.

If as you say you don't even get that far because
state.inventory[state.inventory.carried] == "TVCable" is never true,
then I would suggest inserting
pipmak.print(state.inventory[state.inventory.carried])
or examining state.inventory using the table inspector from the Lua
command line to find out what it is.

  -Christian


------------------------------------------------------------------------------
Write once. Port to many.
Get the SDK and tools to simplify cross-platform app development. Create
new or port existing apps to sell to consumers worldwide. Explore the
Intel AppUpSM program developer opportunity. appdeveloper.intel.com/join
http://p.sf.net/sfu/intel-appdev
_______________________________________________
Pipmak-Users mailing list
[hidden email]
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users


Reply | Threaded
Open this post in threaded view
|

Re: The Inventory

cwalther
Administrator
James C. Wilson wrote:
> However, for the future, I'm not aware of what the list index of the
> object is, or how to find it. If it's the number that the inventory
> table assigns the object

Yes, "index" is a common term for the consecutive numbers that the
"slots" of a list or array are addressed with. Lua by convention starts
counting at 1, most other programming languages start at 0.

If you don't know where in the list the object is, then you just search
for it. The shortest way of doing that I can find right now is

index = table.foreachi(state.inventory, function(i, v) if v == "TVCable"
then return i end end)

although you can also spell it out as

for i = 1, table.getn(state.inventory) do
   if state.inventory[i] == "TVCable" then
     index = i
     break
   end
end

> wouldn't that be biased toward the order in which the player picks up
> items?

Yes, the inventory keeps objects in the order they were picked up. If
you don't like that and would rather have them e.g. in a fixed order,
you need to change the inventory code.

  -Christian



Reply | Threaded
Open this post in threaded view
|

Re: The Inventory

James C. Wilson
Okay, thanks for making that clearer:)


From: Christian Walther <[hidden email]>
To: [hidden email]
Sent: Friday, January 6, 2012 4:52 AM
Subject: Re: The Inventory

James C. Wilson wrote:
> However, for the future, I'm not aware of what the list index of the
> object is, or how to find it. If it's the number that the inventory
> table assigns the object

Yes, "index" is a common term for the consecutive numbers that the
"slots" of a list or array are addressed with. Lua by convention starts
counting at 1, most other programming languages start at 0.

If you don't know where in the list the object is, then you just search
for it. The shortest way of doing that I can find right now is

index = table.foreachi(state.inventory, function(i, v) if v == "TVCable"
then return i end end)

although you can also spell it out as

for i = 1, table.getn(state.inventory) do
  if state.inventory[i] == "TVCable" then
    index = i
    break
  end
end

> wouldn't that be biased toward the order in which the player picks up
> items?

Yes, the inventory keeps objects in the order they were picked up. If
you don't like that and would rather have them e.g. in a fixed order,
you need to change the inventory code.

  -Christian


------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
Pipmak-Users mailing list
[hidden email]
news://news.gmane.org/gmane.games.devel.pipmak.user
https://lists.sourceforge.net/lists/listinfo/pipmak-users