Jump to content

getting all resources


Recommended Posts

Posted (edited)

hello, i am trying to loop through all resources but both methods give ridicilous errors

method one

for _,resources in pairs(getResources()) do 
          local name = getResourceInfo(resources,"name") 
      end 

method one: some error at getResourceInfo

-- attempt to concentrate local 'resources' (a userdata value)

method two:

for _,resources in pairs(getElementsByType("resource")) do 
          local name = getResourceInfo(resources,"name") 
      end 

expected getResourceInfo... expected resource-data got resource -- ??????

Edited by Guest
Posted
function displayResources() 
     local resourceTable = getResources()  
     for resourceKey, resourceValue in ipairs(resourceTable) do 
          local name = getResourceName(resourceValue) 
     end 

Posted

wassim please read my looping example again and see better that 'resources' is a table value

@XeoN- that's exactly the same thing i did except you used a variable which won't do anything

Posted

are you kidding me ? its was like that and you'r edit it -_-

method one: some error at getResourceInfo

-- attempt to concentrate local 'resource' (a userdata value)

Last edited by toxicsmoke11 on 01 Jan 2015 02:22, edited 1 time in total.

Posted
    for _,resources in pairs( getResources( ) ) do 
              local name = getResourceInfo( resources, "name" ) or "" 
          end 

Maybe some of your resources info Undefined

Posted

without name i can't proceed.

i have downloaded a random map and here is meta part of info

"race" type="map" name="[DM] Javelin ft. StyLeX - Skilled Club" author="Javelin & StyLeX" version="1.0.1">

also im having problem with expected resource-data got resource warning which causes me to fail to get resources and their info

Posted

turns out that i have forgot this line

if (getResourceInfo(resource,"type") == "map") and (getResourceInfo(resource,"gamemodes") == "race") and getResourceInfo(resource,"name") then 

so if it would find a single resource without that name and map and gamemode thingy, it would abort the script

anyway thanks for help guys

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...