ID:155626
 
Anyways I made a list of jutsu for my Skills Grid and I want to call that list but I'm not sure If I'm doing it correctly, but when I use that only Rinnengan shows in the grid, not the other two Jutsus:

mob/proc/UpdateGrid()
for(var/newlist in src.contents)
src << output(newlist, "Skills.Skill")



And I have all the Skillcards added to contents using the list

src.contents += newlist(/obj/Skillcards/Ninjutsu/Ama,/obj/Skillcards/Ninjutsu/Byakugan,/obj/Skillcards/Ninjutsu/Rinnengan)


ANy help is appreciated

It's pretty much only showing the last SKillcard, instead of all of them
When updating a grid, you have to specify which cell you're updating, otherwise it just updates the same one. You can specify the cell by using a colon after the grid name in the second argument of output(). From the skin reference:

You can send output to a particular grid cell without having to use winset() first to change the current-cell. Instead of just using the grid's ID in output(), use "[id]:[column],[row]" instead. Or if the grid is using is-list, "[id]:[item]" will do.

Read Lummox JR's Making skins in BYOND 4.0: Lesson 2 for how to use grids. I also recommend reading the other three parts if you're just getting into interfaces. However, note that it was written before the shorthand I mentioned above was implemented, back when you had to winset() which cell you were updating (the stone ages!).
In response to DarkCampainger
DarkCampainger wrote:
When updating a grid, you have to specify which cell you're updating, otherwise it just updates the same one. You can specify the cell by using a colon after the grid name in the second argument of output(). From the skin reference:

You can send output to a particular grid cell without having to use winset() first to change the current-cell. Instead of just using the grid's ID in output(), use "[id]:[column],[row]" instead. Or if the grid is using is-list, "[id]:[item]" will do.

Read Lummox JR's Making skins in BYOND 4.0: Lesson 2 for how to use grids. I also recommend reading the other three parts if you're just getting into interfaces. However, note that it was written before the shorthand I mentioned above was implemented, back when you had to winset() which cell you were updating (the stone ages!).




So like this?

mob/proc/UpdateSkillsGrid()
for(var/newlist in src.contents)
src << output:[newlist]:[Skills.Skill])


or


mob/proc/UpdateSkillsGrid()
for(var/newlist in src.contents)
src << output:"[Skills.Skill]":"[newlist]"




I get 2 errors with the second one so I'm doing it wrong either way


Grids.dm:40:error: "[Skills.Skill]": expected end of statement

Grids.dm:40:error: expected expression
In response to Chaorace
I also have a runtime error, I edited my updateskillgrid proc, I get a runtime error though using any one of them.


mob/proc/UpdateSkillsGrid()
if(!usr.client)return
var/grid_item = 0
for(var/newlist in src.contents)
src << output(newlist, "Skills.Skill")
if(!usr.client)return
winset(newlist, "Skills.Skill", "cells=[grid_item]x2")


This is the runtime error:


runtime error: bad client
proc name: UpdateSkillsGrid (/mob/proc/UpdateSkillsGrid)
usr: Chaorace (/mob)
src: Chaorace (/mob)
call stack:
Chaorace (/mob): UpdateSkillsGrid()
Chaorace (/mob): Login()




In response to Chaorace
You tack the cell onto the end of the second argument of output(), like so:

src << output(newlist, "Skills.Skill:1,[++grid_item]")


Also, that second if(!usr.client)return statement inside the loop is useless, and should really be src.client anyway.

The first parameter to winset() is the client or mob that you're updating (hence why you're getting a "bad client" error when passing it an item). There's also no reason to call it for every item in your contents. Rather, it should be called at the end, outside of the loop. It should read something like this:

winset(src, "Skills.Skill", "cells=1x[grid_item]")
In response to DarkCampainger
DarkCampainger wrote:
You tack the cell onto the end of the second argument of output(), like so:

src << output(newlist, "Skills.Skill:1,[++grid_item]")

Also, that second if(!usr.client)return statement inside the loop is useless, and should really be src.client anyway.

The first parameter to winset() is the client or mob that you're updating (hence why you're getting a "bad client" error when passing it an item). There's also no reason to call it for every item in your contents. Rather, it should be called at the end, outside of the loop. It should read something like this:

winset(src, "Skills.Skill", "cells=1x[grid_item]")





Thank you thank you thank you. Why didn't I realize it was that easy >_<. I'm also new at coding and I read Lummox's grid guide thing like 10 times to try and figure it out aswell. Not to bother, but can you explain what the :1 at the end of Skills.Skill does and the [grid_item] without the ++ does aswell. Thanks!
In response to Chaorace
Chaorace wrote:
...but can you explain what the :1 at the end of Skills.Skill does and the [grid_item] without the ++ does aswell. Thanks!

Sure, as can be found in the skin reference, this is the shortcut for the grid output:
Ref << output("Output value", "[grid ID]:[column],[row]")
So if you wanted to output something to column 3, row 2, you would do 'grid:3,2'

The grid_item variable used keeps track of which column/row the item is outputted in.

++var and var++ both increases the variable by 1. The difference between the two is that ++var returns the new value while var++ returns the old value THEN adds 1.
In response to GhostAnime
Oh I see. Thanks for explaining :D I'm just doing these things off of what I see since some guides around here don't explain things for newbies other then Lummox's.
In response to Chaorace
Also, is there a way to just call the path obj/Skillcards

src.contents += newlist(/obj/Skillcards/Ninjutsu/Ama,/obj/Skillcards/Taijutsu/Byakugan,/obj/Skillcards/Ninjutsu/Rinnengan)


Because I dont want to have to add every dang Skillcard to contents that would be a lot of work. The SKillcards are coded like

obj
Skillcards
Ninjutsu
icon = 'Hotkeys.dmi'
JutsuType = "Ninjutsu"

Ama
icon_state = "Amaterasu"
name = "Amaterasu"
Click()
alert("Test")//IM guessing you'd put the Jutsu to perform here to run after you click.
Rinnengan
icon_state = "Rinnengan"
name = "Rinnengan"
Click()
alert("Test")
Taijutsu
icon = 'Hotkeys.dmi'
JutsuType = "Taijutsu"
Byakugan
icon_state = "Byakugan"
name = "Byakugan"
Click()
alert("Test")
In response to Chaorace
Yep, typesof() is what you want:
misc
fruit
apple
banana

for(var/A in typesof(/misc))
// will refer to /misc/fruit
for(var/B in typesof(A))
// will refer to apple and banana

Print out to the world what A and B appears as, its been a while...
In response to GhostAnime
GhostAnime wrote:
Yep, typesof() is what you want:
> misc
> fruit
> apple
> banana
>
> for(var/A in typesof(/misc))
> // will refer to /misc/fruit
> for(var/B in typesof(A))
> // will refer to apple and banana

Print out to the world what A and B appears as, its been a while...


I fail at this, I'm already confused >_<

for(var/Skillcards in typesof(/obj))

for(var/Ninjutsu in typesof(Skillcards))



Sorry I'm a noob, I'm like 100% sure I'm doing this completely wrong, do you have any resources?
In response to Chaorace
What you need to do is loop through all of the relevant type paths, call new on them, and add them to your contents list.

GhostAnime showed you one method for looping through the types, but I would suggest using this Nulliparous Type Paths Snippet for getting a list of leaf types (a type without children; so /obj/Skillcards/Ninjutsu/Ama would be a leaf type, but /obj/Skillcards/Ninjutsu/ would not be).

You would use the snippet like so:
for(var/T in nulliparae(/obj/Skillcards/))
contents+= new T()
In response to DarkCampainger
DarkCampainger wrote:
What you need to do is loop through all of the relevant type paths, call new on them, and add them to your contents list.

GhostAnime showed you one method for looping through the types, but I would suggest using this Nulliparous Type Paths Snippet for getting a list of leaf types (a type without children; so /obj/Skillcards/Ninjutsu/Ama would be a leaf type, but /obj/Skillcards/Ninjutsu/ would not be).

You would use the snippet like so:
for(var/T in nulliparae(/obj/Skillcards/))
> contents+= new T()



OH thanks for that guide.

Also The new T() what does that do. Like T stands for
nulliparae(/obj/Skillcards/))
?
In response to Chaorace
Chaorace wrote:
Also The new T() what does that do. Like T stands for
nulliparae(/obj/Skillcards/))
?

While the for() loop goes through each index in the list returned by nulliparae(), it sets T to the value at that index. So T will be set to each type path of your Skillcards. Using new T() creates a new object of the type held in T. So together, the loop goes through all of the types returned by nulliparae(), creates them, and adds them to your contents.
In response to DarkCampainger
Oh I see, I might use that more often :P