Gamestudio Links
Zorro Links
Newest Posts
WFO Training with parallel cores Zorro64
by Martin_HH. 02/24/26 19:51
Zorro version 3.0 prerelease!
by TipmyPip. 02/24/26 17:09
ZorroGPT
by TipmyPip. 02/23/26 21:52
Camera always moves upwards?
by clonman. 02/21/26 09:29
Sam Foster Sound | Experienced Game Composer for Hire
by titanicpiano14. 02/19/26 13:22
AUM Magazine
Latest Screens
Dorifto samurai
Shadow 2
Rocker`s Revenge
Stug 3 Stormartillery
Who's Online Now
5 registered members (Martin_HH, TipmyPip, AndrewAMD, Grant, USER0328), 5,287 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
alx, ApprenticeInMuc, PatrickH90, USER0328, Sfrdragon
19199 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
integer test result #146768
08/08/07 12:41
08/08/07 12:41
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline OP
User
Ottawa  Offline OP
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
HI!

Could you try this script at your end?
The results that I get from this is
variable 351.0000
integer 0.3427

I tought that an integer was a whole number.
Code:
#include <acknex.h>
#include <default.c>
//
var _p = 0;
int iP = 0;

TEXT* Vname =
{
pos_x= 90;
pos_y= 90;
layer 8;
STRING = "Variable";
flags |= VISIBLE;
}
TEXT* intname =
{
pos_x= 90;
pos_y= 120;
layer 8;
STRING = "Integer";
flags |= VISIBLE;
}

PANEL* Check =
{
pos_x = 200;
pos_y = 90;
layer 8;
digits (0,0,5.5,*,1,_p);
digits (0,30,5.5,*,1,iP);
flags |= visible;
}
function test_var_int ()
{
while (_p <= 350)
{
_p += 1;
iP += 1;
wait (1);
}
}

function main()
{
wait (1);
// now load the level
level_load("");
wait (3);
test_var_int ();
}




Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: integer test result [Re: Ottawa] #146769
08/08/07 13:03
08/08/07 13:03
Joined: Apr 2005
Posts: 3,815
Finland
Inestical Offline
Rabbit Developer
Inestical  Offline
Rabbit Developer

Joined: Apr 2005
Posts: 3,815
Finland
this has to be bug.. Int indeed means integer, an "whole number".


"Yesterday was once today's tomorrow."
Re: integer test result [Re: Inestical] #146770
08/08/07 14:08
08/08/07 14:08
Joined: Aug 2000
Posts: 1,141
Baunatal, Germany
Tobias Offline

Moderator
Tobias  Offline

Moderator

Joined: Aug 2000
Posts: 1,141
Baunatal, Germany
Here is the bug:

digits (0,30,5.5,*,1,iP );

Digits is var, not int.

Re: integer test result [Re: Tobias] #146771
08/08/07 23:05
08/08/07 23:05
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline OP
User
Ottawa  Offline OP
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi guys/girls!

1) If digits is a var and I want to show integers in a panel what do I use?

2) When I changed the INT for VAR to all my variables it made a big difference in my game.
The panels started to show the right values.
(btw : these panels are for debugging)
and my game is going further than it was.(still a few migration bugs).

VAR seems to be acting like an integer and INT seems to be acting like???


Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: integer test result [Re: Ottawa] #146772
08/09/07 01:06
08/09/07 01:06
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
1.) you can write "(var)YourIntegerVariable" or assign the integer to a var variable like "MyVar = (var)MyInt;" and use the var variable in the panel.

2.) An int is an int surprisingly. And a var is from the data type fixed. Vars don't behave like integers. Never.


Always learn from history, to be sure you make the same mistakes again...
Re: integer test result [Re: Uhrwerk] #146773
08/10/07 13:27
08/10/07 13:27
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline OP
User
Ottawa  Offline OP
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi !

Thanks for the (var) solution but....

I believe that this (var) is a workaround and a fact that INT as a problem.

In any program, if I write 1 = 1 ...I am expecting to get 1 = 1.

When we define a VAR we get 1 = 1
But
when we use INT we get 1 = 0.00098 and in order to correct this
I have to use myint = (var)1 to get 1 = 1
which means that (var) works but INT does not.


Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: integer test result [Re: Ottawa] #146774
08/10/07 13:47
08/10/07 13:47
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
int works, just not all functions work with int. When a function expects a var and you pass an int, the raw binary data in the int will be interpreted as a var. Because a var stores values differently than an int, the same binary data will represent another value when interpreted as var.

To "translate" the value from int to var, you use typecasting. Typecasting is needed in every C compiler so it is not a lite-c bug. The typecasting syntax is (typeToCastTo)variable. Example:
myInt = (int)myFloat;

If a function takes a var, and you have an int you want to pass, you must typecast it:

var myFunction(var x){...}
myFunction((var)myInt);

Apparently, the panel expects a var so you must typecast your int to a var before giving it to the panel.

Re: integer test result [Re: Excessus] #146775
08/10/07 22:35
08/10/07 22:35
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline OP
User
Ottawa  Offline OP
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
HI Excessus!

Thanks for the information.
I've copied it and will look at it.

I will also look for int transfers in function.




Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: integer test result [Re: Ottawa] #146776
08/11/07 12:59
08/11/07 12:59
Joined: Apr 2006
Posts: 737
Ottawa, Canada
O
Ottawa Offline OP
User
Ottawa  Offline OP
User
O

Joined: Apr 2006
Posts: 737
Ottawa, Canada
Hi!
To continue the saga....of typecasting... or another type of problem...

This line was working in Cscript ...the migration is very hard on it :

if (var_green == MyEntity.skill16) {}

var_green is defined as a VAR


but what is MyEntity.skill16 which holds a value of 1.00 to 10.00 in WED.

If it’s an INT how do I typecast it? (I’ve tried a few ways without success )


Hope this helps!
Ottawa laugh

Ver 7.86.2 Pro and Lite-C
Re: integer test result [Re: Ottawa] #146777
08/11/07 13:08
08/11/07 13:08
Joined: Jan 2004
Posts: 2,013
The Netherlands
E
Excessus Offline
Expert
Excessus  Offline
Expert
E

Joined: Jan 2004
Posts: 2,013
The Netherlands
AFAIK, skills are var, so no need to typecast. Are you getting compilation errors, crashes or strange behaviour without typecasting?

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1