ID:156750
 
I am having trouble with a demo I am trying to create. It is simply not working for some strange reason. This is what is supposed to happen.

Double-Clicking on one of inventory objects:
  • After entering a number from 1 to 10 (decimals are rounded down), that object is added to a list (The value of current_set_list) called grid_objoverlay, which is a multi-dimensional list of [6][10] ([current_set_list][number]). This then runs a proc which will add the overlay to the screen object specified. I am not sure if this even happens or not, but it is not visible if it does.

Clicking an arrow, UP or DOWN:
  • The current_set_list value is edited appropriately.

  • The overlays in the selected list are added onto the screen objects.

The demo is downloadable through this link:

http://www.quickfilepost.com/ download.do?get=82e61dd774152585d5a5d060de95e6d6

And this is the source code:

#define Move_Up 5 //These are just used to make it an easier concept to have
#define Move_Down 10 //numbers set for a variable, but instead you can use text that equals those numbers

world //Basic world setup to test demo
maxx = 10
maxy=10
maxz=1

client/view = 7 //Your view

atom/icon = 'Icons.dmi' //Icon setting for objs,areas,turfs,mobs is Icons.dmi

world/mob = /mob/player //Set the world's mob

mob/player/Login()
Maximize() //Maximize your screen
client.screen += cardobjects //Add a list of objects
usr.contents += testOBJS


mob/player/Stat()
statpanel("Iventory", usr.contents) //Have a statpanel that shows the client's mob's contents

mob/player/var/tmp/never //Set up a variable for the verb

mob/player/verb/True_False_Checker() //This verb is just an example for the NOT operator
set hidden = 1
if(never) //Check if it is true
never = null //Setting to null is like setting to false
usr << "Never = False(null)"
else if(!never) //Check if it is false (You can also just use else)
never = 1 //Setting to 1 is like setting to true
usr << "Never =True(1)"

mob/proc/Maximize()
winset(src,"window1", "is-maximized=true") //Maximize your window

////////////////////////////////////////////////////////////////////////////////////////////////////////////
obj
skillcards
icon_state = "normal"
layer = 6 //Give it a layer higher than anything else
MouseEntered() //When the mouse enters
icon_state = "mouseover" //change the icon
MouseExited() //When the mouse exits
sleep(1) //Wait 1/10 of a second
icon_state = "normal" //change the icon
s_one
screen_loc = "1,1" //The X and Y Locations on screen
s_two
screen_loc = "2,1"
s_three
screen_loc = "3,1"
s_four
screen_loc = "4,1"
s_five
screen_loc = "5,1"
s_six
screen_loc = "6,1"
s_seven
screen_loc = "7,1"
s_eight
screen_loc = "8,1"
s_nine
screen_loc = "9,1"
s_zero
screen_loc = "10,1"

obj
buttons
var/mob/player/P
UP
icon_state = "up"
screen_loc = "5,6"
Click()
src.P = usr //set up the mob variable defined for the client
if(P.allowed)
P << "[P.allowed] - P.allowed <b>if #1</b>"
P.allowed = null
P << "[P.allowed] - P.allowed <b>if #2</b>"
P.direction = Move_Up //set variable value(defined at top)
P.list_iteration()
P.set_macros()
else
P << "[P.allowed] - P.allowed"
MouseEntered()
icon_state = "flickup"
MouseExited()
sleep(1)
icon_state = "up"
DOWN
icon_state = "down"
screen_loc = "5,5"
Click()
src.P = usr //set up the mob variable defined for the client
if(P.allowed)
P << "[P.allowed] - P.allowed <b>if #1</b>"
P.allowed = null
P << "[P.allowed] - P.allowed <b>if #2</b>"
P.direction = Move_Down //set variable value(defined at top)
P.list_iteration()
P.set_macros()
// P.allowed = 1
else
P << "[P.allowed] - P.allowed"
MouseEntered()
icon_state = "flickdown"
MouseExited()
sleep(1)
icon_state = "down"

mob/player/var/tmp/allowed = 1 //Variable to check whether Scroll_List() is currently being used or not

mob/player/var/tmp/direction //This is used to tell list_iteration whether to increase or decrease(Move_Up,Move_Down)

mob/player/var/tmp/neverclicked

obj
test_objects
var/mob/player/P
DblClick()
src.P = usr //set up the mob variable defined for the client
if(!P.neverclicked)
P.neverclicked = 1
switch(alert("Would you like to macro this?",,"Yes","No"))
if("Yes")
var/number = round(input(P,"Which key would you like to macro this to? Enter a number between 1 and 10 (Decimals will be rounded down).","Input") as num)
if(number < 1||number > 10)//Don't allow them to enter an improper value
usr << "Value entered was too small/large. Please enter a value between 1 and 10."
P.neverclicked = null
return
else
var/obj/OO = P.grid_objoverlay[P.current_set_list][number]
OO = null
OO += src
P << "<font color=blue>[OO] : OO</font> , <font color=purple>[src] : src</font> , [P.current_set_list] : P.current_set_list , <font color=red>[number]: number</font>"
//a check for current values of things, just for good measure
P.set_macros()



layer = 7
purple
icon_state = "purple"
blue
icon_state = "blue"
green
icon_state = "green"
red
icon_state = "red"
orange
icon_state = "orange"



var/list/testOBJS = newlist(/obj/test_objects/purple,/obj/test_objects/blue,/obj/test_objects/green,/obj/test_objects/red,/obj/test_objects/orange)
//This list is added to your contents when you login, under Other.dm

mob/player/var/list/grid_objoverlay[6][10] //Multi-Dimensional list for icon overlays (6 sets of 10)

mob/player/var/list/grid_macrocommand[6][10] //Multi-Dimensional list for macro commands (6 sets of 10)


var/list/cardobjects = newlist(/obj/skillcards/s_one,/obj/skillcards/s_two,/obj/skillcards/s_three,/obj/skillcards/s_four,/obj/skillcards/s_five,/obj/skillcards/s_six,/obj/skillcards/s_seven,/obj/skillcards/s_eight,/obj/skillcards/s_nine,/obj/skillcards/s_zero, /obj/buttons/UP, /obj/buttons/DOWN)
//This list is of the objects that are added to the client's screen upon login

mob/player/var/tmp/current_set_list = 1 //The value of the lists you are using

mob/player/var/tmp/keep_iterating = 1 //Variable to allow the for() loop to continue

mob/player/proc/set_macros()
var/a = 0 //Check if the for(a<10) can still run
var/b = 1 //The first place in cardobjects list
var/c = 1 //The first place in grid_objoverlay

var/obj/CO = cardobjects[b]
var/obj/OO = grid_objoverlay[current_set_list][c]
// list_iteration() //Call this when using arrows, before running set_macros() proc
keep_iterating = 1
if(keep_iterating)
while(a<10)
src << "[CO] : CO , [OO] : OO <b>Check 1</b>"

CO.overlays = null

src << "[CO] : CO , [OO] : OO <b>Check 2</b>"

CO.overlays += OO

src << "[CO] : CO , [OO] : OO <b>Check 3</b>"
/*

Here is where I need to assign the proper macros
to each button, based on the current_set_list
with the grid_macrocommand list

*/

a++
b++
c++

src << "<hr></hr>[a] : a, [b] : b, [c] : c<br></br>"

while(a>=10) //This will take effect when 'a' = 10 from the for() loop
keep_iterating = null
a = 0


mob/player/proc/list_iteration()

if(direction==Move_Up)
current_set_list++
if(current_set_list>6) //If bigger than 6, make it 1
current_set_list = 1

else if(direction==Move_Down)
current_set_list--
if(current_set_list<1) //If less than 1, make it 6
current_set_list = 6


I have no idea what is flawed. If you can help at all, please do, and thank-you.
                            var/obj/OO = P.grid_objoverlay[P.current_set_list][number]
OO = null
OO += src


The first two lines, together, do nothing: you are storing something into a variable, then setting it to null. The third line then attempts to add an object to null, which really shouldn't be possible but because it is it just sets the value of OO to src.

You need to instead just change this to one line, setting grid_objoverlay[what][ever] to src.

You also have a lot of other stupid things, like:

    keep_iterating = 1
if(keep_iterating)


GEE I WONDER WHAT keep_iterating IS GOING TO BE!!!

And, I can't provide a snappy little snippet, but the way in which you are using mob variables to pass arguments in the wrong way to procedures which take no arguments is really, really poor design. For instance:

mob/player/proc/list_iteration()

if(direction==Move_Up)
current_set_list++
if(current_set_list>6) //If bigger than 6, make it 1
current_set_list = 1

else if(direction==Move_Down)
current_set_list--
if(current_set_list<1) //If less than 1, make it 6
current_set_list = 6


direction should not be a mob variable here. It should be a variable passed to this procedure. And it really should just be either +1 or -1, instead of using those if() statements.

Oh, and on another note: constants should be in ALL_CAPS.


Honestly, you are not the kind of person who should be making a demo.
In response to Garthor
GEE I WONDER WHAT keep_iterating IS GOING TO BE!!!

I think I just peed a bit from laughter
In response to Garthor
In a multiplayer enviornment, how could I go about specifying the object variable for each person? Wouldn't it just edit the variable for the whole world if I did

var/direction


?

I am confused on a basic here I guess. How can an object have a variable, and have that object's variable be specified for each person, such as if the client.screen arrow objects had the direction variable set for them?
In response to Darkjohn66
In response to Garthor
Ah, that completely left my mind. Thanks for your help.

Honestly, you are not the kind of person who should be making a demo.

Saying things like that just keeps me striving even more.