ID:156882
 
I am making a round based game, and I would like the list of players, as well as the "Join Game" verb to be in the same panel, but even if I make "Join Game" in say the "Game Info" category, and the players list be in the "Game Info" category, it makes two seperate categories (one being done by a basic verb thing, and the other with a statpanel proc), please tell me how this can be done. I know it's possible because it's done in Mitadake High.
Its not possible
I don't know what they do in MH, but to simulate such a thing you can make objects listed in the same panel with the players, which execute verbs in their Click()
In response to Falacy
I realized that, and then I made in an obj, but the obj will only let me change usr. vars, if I want to change one that will be throughout the whole game, a global var, it won't work. It will say "Varname undefined var".
In response to Xyphon101
Xyphon101 wrote:
if I want to change one that will be throughout the whole game, a global var, it won't work. It will say "Varname undefined var".

Then you're doing something wrong
In response to Falacy
Ok, everything seems to be in order, but I have a slight issue, which is possibly unrelated.

I have it set up to do this:
Players+=1
usr.Joined=1
players.Add(usr)

Players and Joined works fine, and then I have a statpanel doing this:
mob
Stat()
statpanel(players)
stat(Join_Game)
Unfortunately, the players list shows nothing in the statpanel, nothing, but the Join button is still there.
Little help?
In response to Xyphon101
statpanel is used to change the panel. stat is used to add an object to the panel.
In response to Pirion
Pirion wrote:
statpanel is used to change the panel. stat is used to add an object to the panel.

Unfortunately, stat(players) doesn't work either, neither does statpanel("Stats",players)
Weird, if I make the var be usr.players, and I display usr.players, it works fine. Why won't it work without that?
In response to Xyphon101
Wouldn't a for loop be handy to show the players from the players list?
In response to Howey
mob
Login()
..()
players += src

Stat()
..()
statpanel("Players")
for(var/i=1, i<=players.len, i++)
stat("Name:",players[i])

var
list
players = list()



As for the having a verb, *shrugs*
In response to Howey
Howey wrote:
Wouldn't a for loop be handy to show the players from the players list?

No. That would be horribly inefficient and would end with more or less the same results.
This should be completely possible, hes just doing something(?) wrong.
In response to Xyphon101
Is players defined to the mob, and the top level? did you initiate the list?

I would try changing the variable to something else to test
var/list/in_players = new()
mob
Stat()
stat(in_players)
verb/join()
in_players+=src


Tested and verified that this works as intended.
In response to Pirion
No, because the Players var (number of players joined, different than the list) doesn't work either. Maybe I should show you my entire code.
var/obj/Join_Game
world
New()
..()
global.Join_Game = new/mob/obj/Join
mob/obj
Join
Click()
Players+=1
usr.Joined=1
players.Add(usr)
mob/Login()
if(GameInProgress)
usr.icon = 'Ghost.dmi'
usr.invisibility=1
usr.see_invisible=1
usr.loc = locate(37,28,1)
usr.Type="Spectator"
winset(src,"child1","left=window3")
usr.Spectator=1
else
if(usr.key=="Xyphon101")
usr.verbs+= typesof(/mob/Host/verb)
usr.icon = 'Turfs.dmi'
usr.loc = locate(11,490,1)
usr.Type="Person"
winset(src,"child1","left=window2")
mob
Stat()
statpanel("Game_Info",players)
statpanel("Game_Info",Players)
stat(global.Join_Game)


I think the problem is that on Click() it is reading it as usr, but it won't let me read it as anything else, like world. or client., except for src but that wouldnt work.
In response to Xyphon101
mob
statpanel("Game Info")
stat(players)
stat(Players)
stat(global.Join_Game)
In response to Xyphon101
There's really no point in having a numerical player count, and a list of the same players. You can just use Players.len on the list
In response to Unwanted4Murder
Maybe neither of you understood, but that's not the problem. The problem is that on my Click() the var players and Players isn't reading properly at all.

No matter how I do it, stat(players) doesn't work.

The only way I can get it to work is if I make it a usr. var, but obviously that won't work. It will let me define it as an src var, but it won't work properly.

I'm seriously starting to doubt any of you understand the problem at all.

Also, mob/statpanel() doesn't work without the Stat() proc.
In response to Xyphon101
Where did you define the players list?

Also corrected this:
mob/Stat()
> statpanel("Game Info")
> stat("Who",players)
> stat("Total",players.len)
> stat(global.Join_Game)
In response to Xyphon101
I think the problem is that on Click() it is reading it as usr, but it won't let me read it as anything else, like world or client, except for src but that wouldnt work.

That isn't the problem.

Show where you're defining Players and players.
In response to Keeth
mob/var
Players
players[] = list()
In response to Xyphon101
What is the logic behind defining the list of players (or the player count) on the mob type? Also, same question for defining your button as /mob/obj. I really don't understand that at all.

In any case. It's pretty obvious the problem here is that you are trying to access your mob's local players and Players values, when the value actually being changed on clicks is your /mob/obj/Join's.

[edit] this is what your code is doing
mob
obj
Join
Click()
src.Players++ // increase this mob's (the Join button's) Player count
src.players += usr // add the clicker to this mob's (the Join button's) players list

Stat()
statpanel("Players")
stat(src.players) // access the local definition of players (specifically, this mob's) and print it.
stat("There are [src.Players] players online.") // access the local definition (specifically, this mob's) of Players and print it.


I think you are under the misconception that defining a variable under mob is somehow creating a global definition. It isn't. Every mob now has their own players list. In Stat(), it is printing that specific mob's data, and when you click the Join button, it is increasing the Join object's player count and such.

This should either be a global variable (by the way, you don't need to prepend things with global unless there is some discrepancy between the local scope and the global scope, like two variables with the same name), or you consistently access the proper object storing your data (in this case, the Join button). Though a global value might make more sense.
In response to Keeth
Maybe you missed it, but I said previously that I tried src, as it allowed me to do so, and it did not work.
Page: 1 2