Jump to content


Photo

Can not compare arguments


  • Please log in to reply
5 replies to this topic

#1 Hokkaido

Hokkaido

    GMC Member

  • New Member
  • 114 posts
  • Version:GM8

Posted 25 November 2011 - 08:26 PM

Hello, I am making this game now I have a simple code drawing the value of something but I get this wierd error 'Can not compare arguments'.

Here is the code for checking it

//Als hij meer is dan 1 dan doet hij de sprite drawen anders een vierkant
for(i:=0; i<=15; i+=1) //i = 0 en als i minder is dan 15 dan gaat hij een meer en hij doet dan alle items na gaan als je die i<15 veranderd in i<100 gaat hij het 100 keer na
{
if global.inventory[i,4]>0 then //Als er meer dan 0 items zijn
{
draw_sprite(global.inventory[i,2],-1,8.75+i*(32+8.75), 8.75); //Drawt de Sprite van i,2 (Gezegde Sprite)
}
else
{
draw_rectangle(8.75+i*(32+8.75),8.75,8.75+i*(32+8.75)+32, 32+8.75,false); //Maakt een nieuwe vierkant op de coardinaten god laat die goed zijn...
}
}



And the error is in the line

if global.inventory[i,4]>0 then //Als er meer dan 0 items zijn



And here is defined what i,4 is

//Dirt Block
global.inventory[0,0]:='Dirt';
global.inventory[0,1]:='Dirt Block';
global.inventory[0,2]:=spr_grass;
global.inventory[0,3]:='20';
global.inventory[0,4]:='0';
global.inventory[0,5]:='';


  • 0

#2 wimlore

wimlore

    GMC Member

  • GMC Member
  • 124 posts

Posted 25 November 2011 - 08:35 PM

Gutentag! Sorry I could not read your comments.

If global.inventory[0,0] never goes to [15,0] then your problem is i. [i,#]. But if you have a global.inventory[15,4] then you're okay as far as the array index actually existing.

In your for loop statement it says i<=15;, this will actually check the inventory all the way up to [16,4]. So maybe if you made it i<15, it would fix it. :unsure:
  • 0

#3 Hokkaido

Hokkaido

    GMC Member

  • New Member
  • 114 posts
  • Version:GM8

Posted 25 November 2011 - 08:47 PM

Gutentag! Sorry I could not read your comments.

If global.inventory[0,0] never goes to [15,0] then your problem is i. [i,#]. But if you have a global.inventory[15,4] then you're okay as far as the array index actually existing.

In your for loop statement it says i<=15;, this will actually check the inventory all the way up to [16,4]. So maybe if you made it i<15, it would fix it. :unsure:


I have no idea about what comments you're talking about thanks it got fixed :D.

Either way one more problem:


Error in code at line 30:
if global.inventory[i,4]>=0 then //Als er meer dan 0 items zijn
^
at position 31: Cannot compare arguments.

Edit:

Oh those comments they are for my friend and they are Dutch not German :verymad:

Edited by Hokkaido, 25 November 2011 - 08:48 PM.

  • 0

#4 wimlore

wimlore

    GMC Member

  • GMC Member
  • 124 posts

Posted 25 November 2011 - 09:10 PM

I see an issue! You are comparing a string to a real number.

You are declaring global.inventory[0,4]:='0'; as a string, using the '' symbols around the number.
You can either do this: global.inventory[0,4]=0; making it a number instead of a string.

or in the comparison code do this:

if real(global.inventory[i,4])>=0 then

-Converting the string into a real number.
  • 0

#5 Hokkaido

Hokkaido

    GMC Member

  • New Member
  • 114 posts
  • Version:GM8

Posted 25 November 2011 - 09:26 PM

I see an issue! You are comparing a string to a real number.

You are declaring global.inventory[0,4]:='0'; as a string, using the '' symbols around the number.
You can either do this: global.inventory[0,4]=0; making it a number instead of a string.

or in the comparison code do this:

if real(global.inventory[i,4])>=0 then

-Converting the string into a real number.


Thanks all my problems are solved. You are a great helper. ;)
  • 0

#6 wimlore

wimlore

    GMC Member

  • GMC Member
  • 124 posts

Posted 25 November 2011 - 10:23 PM

Thanks all my problems are solved. You are a great helper. ;)

I really appreciate that comment, thanks and good luck with your project :medieval:
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users