Looping through items?

Need help with your script? Want to know how to do something? Want to post an example? Post it here!

Looping through items?

Postby sci4me » Fri Nov 28, 2014 1:37 am

Hey guys, just getting into MineTweaker 3 and I gotta say, I am VERY impressed.

So, I am currently trying to loop through EVERYTHING:

: [Select all] [/] [] ()
val all = <*>;

for i, item in all.items {

GeSHi © Codebox Plus

And it says "Error executing Tweaks.zs: null"

The reason I tried .items was because of "<ore:ingotCopper>.items"... I assumed it would work the same way. Can this be done? If so, how?

EDIT: I tried the ores one and it does the same thing? o.O
Posts: 1
Joined: Fri Nov 28, 2014 1:33 am

Re: Looping through items?

Postby Stan » Tue Dec 02, 2014 7:58 am

<*> happens to be the only place where .items doesn't work. (.items returns null in case of the wildcard)

It is actually not completely possible to loop through every possible sub-item in the game. It _is_ possible, though, to loop through every item definition, with game.items:

: [Select all] [/] [] ()
  1. for itemDefinition in game.items {
  2.    ...do something for every item definition...
  3.    ... you can do itemDefinition.makeStack(meta) to create an actual item stack ...
  4.    ... or itemDefinition.id to get the id ...
  5.    ... or itemDefinition.name to get the internal name ...
  6. }
GeSHi © Codebox Plus

However, that would get you item definitions (not item stacks) and thus wouldn't take into account possible meta values. There is, unfortunately, no reliable method to determine which sub-items are available for a specific item.

For <ore:ingotCopper>.items, it is supposed to work, but I notice there is indeed an error being thrown somewhere - so that's a bug.
User avatar
Site Admin
Posts: 258
Joined: Fri Jul 11, 2014 9:04 pm

Re: Looping through items?

Postby cenigyh » Wed Jan 08, 2020 11:04 am

You can have several things that you can accomplish through different sites. Throughout the whole phenomenon top paper writing services are giving the benefits through the help of the topmost people.
Posts: 1
Joined: Wed Jan 08, 2020 11:04 am

Return to Scripting Help

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 2 guests