Help with your scripting

inventory

inventory

Postby TattieBoJangle » 30 Oct 2015, 18:55

Anyone manage to get a inventory up and running ;) or even a carry script.
Case: CM Storm Trooper CPU: I7 5930k X99 Cooler: Noctua NH-D15 Graphics: Asus GTX 1080 Motherboard: Rampage Extreme V x99 Ram: RipJaws DDR4 3000mhz Storage: x2 SSD Crucial 500GB + x5 2TB Hdd PSU: Evga 1500w OS: Windows 10
User avatar
TattieBoJangle
Community Manager
Community Manager
 
Posts: 858
Joined: 26 Jan 2015, 00:15
Location: United Kingdom
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer
Skill: Great creative

Re: inventory

Postby StarFire » 30 Oct 2015, 22:09

If you get no takers, when I get back to the mechanics I will add this request to the current script tasks for you.
Did you know that the pick up action can be used for simpler "carry" tasks, may get you by for now ;)
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: inventory

Postby TattieBoJangle » 30 Oct 2015, 22:59

Ahh yea thanks StarFire :D
Case: CM Storm Trooper CPU: I7 5930k X99 Cooler: Noctua NH-D15 Graphics: Asus GTX 1080 Motherboard: Rampage Extreme V x99 Ram: RipJaws DDR4 3000mhz Storage: x2 SSD Crucial 500GB + x5 2TB Hdd PSU: Evga 1500w OS: Windows 10
User avatar
TattieBoJangle
Community Manager
Community Manager
 
Posts: 858
Joined: 26 Jan 2015, 00:15
Location: United Kingdom
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer
Skill: Great creative

Re: inventory

Postby ant0N » 31 Oct 2015, 11:15

I can write the script of the inventory, but I need one new command - drawImage(image, x,y) ;)
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: inventory

Postby TattieBoJangle » 31 Oct 2015, 11:39

Nice one Anton now only if someone could add the required command (Hint Hint) drawImage(image, x,y) :lol:
Case: CM Storm Trooper CPU: I7 5930k X99 Cooler: Noctua NH-D15 Graphics: Asus GTX 1080 Motherboard: Rampage Extreme V x99 Ram: RipJaws DDR4 3000mhz Storage: x2 SSD Crucial 500GB + x5 2TB Hdd PSU: Evga 1500w OS: Windows 10
User avatar
TattieBoJangle
Community Manager
Community Manager
 
Posts: 858
Joined: 26 Jan 2015, 00:15
Location: United Kingdom
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer
Skill: Great creative

Re: inventory

Postby SolarPortal » 31 Oct 2015, 12:46

why not use the GUI editor? and load the gui on screen.
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: inventory

Postby ant0N » 31 Oct 2015, 15:28

SolarPortal wrote:why not use the GUI editor? and load the gui on screen.

Affairs that I don't know where to start and how to use it.. I am not familiar with css and html. :oops:

And with lua I've done inventory before. Very long ago it was.
Sorry for my English. :)
User avatar
ant0N
Skyline Moderator
Skyline Moderator
 
Posts: 415
Joined: 02 Nov 2012, 12:49
Location: Россия, Москва
Skill: Programmer
Skill: 3D Modeller

Re: inventory

Postby SolarPortal » 31 Oct 2015, 16:06

ahh i see, thats pretty cool though.

HTML and css are a very simple markup language that does not take much time to learn, check out our demos in the "tech demos>GUI folder" and look at the .rml files located in the "Asset Library/GUI/folders...".

A simple draw image would be good though :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer

Re: inventory

Postby CreativeOcclusion » 31 Oct 2015, 16:48

A simple draw image would be good though


+1
Thanks, CreativeOcclusion
User avatar
CreativeOcclusion
Skyline Warrior
 
Posts: 366
Joined: 22 Jun 2015, 19:34
Location: Texas

Re: inventory

Postby StarFire » 31 Oct 2015, 20:42

could be a good visual module to add ( also will add lua ) ;)
Dream the Journey, Live the Experience!
User avatar
StarFire
Skyline Founder
Skyline Founder
 
Posts: 1678
Joined: 03 Jan 2012, 18:50
Location: UK
Skill: Great creative
Skill: Programmer
Skill: 3D Modeller
Skill: 2D Artist
Skill: Level Designer

Re: inventory

Postby epsilonion » 01 Nov 2015, 13:52

I have kind started something not gotten far like.. Just throwing stuff together and sorting out errors later on lol.

Code: Select all
--[[
A quick attempt at a inventory system.

table info.
items.name
items.texture
items.health
items.amount      -- for stackable items such as apples 3

--]]

obj = 0;

-- Set up the inventory
items = {}                                 -- table for the inventory
itemSlots = 10                             -- item slots avialable for the inventory
-- itemSize = = newType.vec2(64,64);       -- Used to set the size of the texture
   
function onInit(objID)                     -- You can preload a table with items if you wanted to
   obj = objID;
   --sky.print("Scene Script Acitve");
end

function Inventory.Add (item)            -- Add items to the Inventory
      for i = 1, itemsSlots, 1 do        -- Look for an empty slot
         if items [i] == nil then        -- If the slot is nil then inset the item into that
            items [i] = item             -- slot
            return                      -- ends the for loop and returns from the function
         end                            -- ** you could check if stack it at its max like 3 apples
      end                               -- if your inventory can only hold 3 apples in a slot   
end

function Inventory.Delete(itemName)         -- Delete Item from inventory
      for i = 1 itemSlots, 1 do             -- can call this if an item is used and no longer
         if items.mane == itemName then     -- available
            item [i] = nil                  -- makes the slot nil so can be populated again
            return                          -- ends the for loop and returns from the function
         end
      end
end

function Inventory.Display ()            -- function used to display the inventory on screen

end

function inHand()                     -- function for items placed from the inventory into a
                                      -- usable slot (taken from a bag into a pocket to be used
                                      -- for instance.
end



Only problem I am having is trying to get it to display in a gui and using the drag function in the GUI..
Going out soon so will get back on it later on.

inventory_gui.lua
updated
(2.41 KiB) Downloaded 442 times
User avatar
epsilonion
Skyline Lead Moderator
Skyline Lead Moderator
 
Posts: 874
Joined: 26 Feb 2015, 11:51
Location: Hull, East Yorkshire, England
Skill: Business Manager
Skill: Great creative

Re: inventory

Postby SolarPortal » 19 Nov 2015, 22:00

Hey,

I have managed to add the ability to change a GUI image during runtime. Because of librocket you have to use the <img> element if you want to change it at runtime and css decorators are currently unchangeable.

You may be thinking, <img> elements have problems being scaled. So if my Inventory is on a lower rez screen and scales all the slots down, i wouldn't be able to add my image to that slot at the right height.

Because the <img> element uses HTML attributes to set the width & height of the image, you cannot use the gui.setProperty() function as this is too handle the style of a element.

Just for reference:

Attributes are:
Code: Select all
<img id="image1" src="myTexture.png" width="128" height="128">
or
<div id="name" style="position: absolute; top: 0; left 0; height:128px; width:128px;" class="myclass">


In the case for the <img>: id, src, width & height are the attributes.
In the case for the <div>: id, style & class are the attributes.

The gui.setProperty() command will only edit the params inside the style="" attribute, so this means position, left, top, height & width are the properties to be edited and these are not attributes.

So i added some new lua commands:

Code: Select all
gui.setAttribute(guiID, elementName, attribute, value)
string = gui.getAttribute(guiID, elementName, attribute)
string = gui.getProperty(guiID, elementName, attribute)


This works identical to the setProperty except it edits attributes like descibed above which means you can change the width and height of an <img> element at runtime.

You can now save yourself a bit of pain when developing, for example.

> Create the inventory empty slot as a <div> tag, set a background-image in the <style> section of the RML files header as this image does not need to change.
> Inside the div, create an <img> element, this will be what you load the textures onto.
> Now in lua, grab the width and height from the div using the new gui.getProperty() command and store these into a variable.
> Set the width and height attributes of the <img> label to match the div property meaning the image will always scale to fit the parent divs container.

First, lets show you the HTML code for setting this up:
Code: Select all
<div id="image1Frame" style="display: inline-block; background: #ff0000; width: 128px; height: 128px;">
    <img id="image1" src="cliff.jpg" width="128" height="128" />
</div>


This is taken straight from my demo, so you can match the ids to the code below.
Now for some lua code displaying below is the lua code to change the image and set the height and width to the div tags size:

Code: Select all
-- | Here is how you change the size of a div tag using the gui.setProperty function. This is a style edit and not an attribute.
-- | You can use gui.setScaleYCent(), gui.setScaleXCent(), gui.setScaleY(), gui.setScaleX() direct for easier to read code, but this is the more raw way lol :P

    gui.setProperty(guiID, "image1Frame", "height", "64")
    gui.setProperty(guiID, "image1Frame", "width", "100")

-- | This is how you change the image texture:
    gui.setAttribute(guiID, "image1", "src", "defaultRoadTextureOther.png") -- Notice the the setAttribute used instead.

-- | Change the size of the <img> to match the <div> by getting the <div> tags width and height properties.
    height = gui.getProperty(guiID, "image1Frame", "height");
    width = gui.getProperty(guiID, "image1Frame", "width");
      
    gui.setAttribute(guiID, "image1", "width", width)
    gui.setAttribute(guiID, "image1", "height", height)


If you match the ids to the <div> & <img> tags, then you should figure it out :)

Anyway, this will be available in the next release but looking forward to seeing some inventories now :)
Skyline Game Engine - Lead Dev.
Please provide as much info as possible when asking for help.


Specs: OS: Win 10 64bit, CPU: Intel i7 4770 3.4ghz x 4 core(8 threads), GPU: Nvidia GTX 1060 6GB, Ram: 16gig DDR3, Windows on 250gb Samsung Evo 860

Twitter: @SolarPortal
Instagram: @SolarPortal
User avatar
SolarPortal
Skyline Founder
Skyline Founder
 
Posts: 3631
Joined: 29 Jul 2012, 15:56
Location: UK
Skill: 3D Modeller
Skill: 2D Artist
Skill: Programmer
Skill: Level Designer


Return to Lua Scripting

Who is online

Users browsing this forum: No registered users and 8 guests

cron