Jump to content


Photo

Ds_lists


  • Please log in to reply
7 replies to this topic

#1 exxod

exxod

    GMC Member

  • New Member
  • 144 posts

Posted 16 September 2009 - 01:17 PM

I have a list using ds_lists. I have never used ds_lists before so i'm kind of confused. The concept is easy to understand but when I used this:
var i, qId;
for (i=0; i<25; i+=1)
{
qId = ds_list_find_value(list,i)
if qId = 0
qId = ''
}

It gives me an error at 'if qId = 0' saying 'Cannot compare arguments'

I found a targeting example from Mark13673 and used those ds_list codes it still gave me an error. Is it because I need to have an 'else' after qId = ''?

Edited by exxod, 17 September 2009 - 10:55 AM.

  • 0

#2 Xdaamno

Xdaamno

    GMC Member

  • New Member
  • 289 posts

Posted 16 September 2009 - 04:19 PM

It's because you're the variable you're checking is a string. You can't compare a string with a number.
  • 0

#3 exxod

exxod

    GMC Member

  • New Member
  • 144 posts

Posted 16 September 2009 - 05:23 PM

It's because you're the variable you're checking is a string. You can't compare a string with a number.

But even when i fix that to be a number it still gives me the error.
  • 0

#4 MrOpposite

MrOpposite

    Yesterdays games

  • New Member
  • 744 posts

Posted 16 September 2009 - 06:17 PM

var i, qId;
for (i=0; i<25; i+=1)
{
	qId = ds_list_find_value(list,i)
	if(is_real(qId))
	{
		if qId = 0
			qId = ''
	}
	else
	{
		if qId = '0'
			qId = ''
	}
}
try that?
  • 0

#5 exxod

exxod

    GMC Member

  • New Member
  • 144 posts

Posted 17 September 2009 - 05:06 AM

Hmm. It seems to be working just fine, but then how would I make it so it draws the value if it is not 0. I have added values that are strings.
  • 0

#6 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5389 posts
  • Version:GM:Studio

Posted 17 September 2009 - 06:16 AM

var i, qId;

for (i=0; i<25; i+=1)

{

	qId = string(ds_list_find_value(list,i)) // I turn it to a string even if it is a real value



	if qId != '-1' and qId!='0'{ // check that it found something, and that it wasn't 0

		draw_text(x+(i div 5)*15,y+(i mod 5)*15,qId) // draw them inventory like 5*5 ..

	}



}
if they are originally real values .. then why store them as strings in the ds list?
  • 0

#7 exxod

exxod

    GMC Member

  • New Member
  • 144 posts

Posted 17 September 2009 - 08:12 AM

var i, qId;
for (i=0; i<25; i+=1)
{
	qId = string(ds_list_find_value(list,i)) // I turn it to a string even if it is a real value

	if qId != '-1' and qId!='0'{ // check that it found something, and that it wasn't 0
		draw_text(x+(i div 5)*15,y+(i mod 5)*15,qId) // draw them inventory like 5*5 ..
	}

}
if they are originally real values .. then why store them as strings in the ds list?

Your code worked perfectly! Thanks. And the reason for storing them as strings is becuase when I added a value that was a string, all the empty places in the list draw themselves as 0. I did not want this.
  • 0

#8 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5389 posts
  • Version:GM:Studio

Posted 17 September 2009 - 05:08 PM

var i, qId;

for (i=0; i<25; i+=1)

{

	qId = string(ds_list_find_value(list,i)) // I turn it to a string even if it is a real value

	if (qId>0) { draw_text(x+(i div 5)*15,y+(i mod 5)*15,string(qId)); }

}
here is the code if you want to use real numbers, then you just check that it isn't 0 or -1 (no value found), if so draw it using string(qId)
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users