IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
Forum Rules GTA Modification Forums

Please post mod releases in the Mod Showroom

GTAGarage.com
free mod hosting from GTANet, simply login with your GTAForums account details

GTAModding.com
GTANet's modding wiki

GTA Modding Chatroom
provided by irc.gtanet.com (Don't have an IRC client? Click here)


  Reply to this topicStart new topicStart Poll

 Convert float to int

 
HeresOtis  
Posted: Wednesday, Jun 13 2012, 01:26
Quote Post


Mark Chump
Group Icon
Group: Members
Joined: Apr 29, 2011

XXXXX



How can I convert an array float into an array integer? With code below, I keep getting 0.

CODE
0AB1: call_scm_func @getAdditionalVarsLabelPointedIndex 2 label @AdditionalVariables divider 4 store_index_to 31@
0653: 0@(31@,1f) = float_stat 24 // Player Max Health
0@(31@,1f) /= 5.69
0092: 0@(31@,1f) = float 0@(31@,1f) to_integer
PM
  Top
 

 
Deji  
Posted: Wednesday, Jun 13 2012, 08:07
Quote Post


Coding like a Rockstar!
Group Icon
Group: Members
Joined: Dec 24, 2007

ja.gif

XXXXX



Tried
CODE
0092: 0@(31@,1i) = float 0@(31@,1f) to_integer

?
Users WebsitePM
  Top
 

 
HeresOtis  
Posted: Wednesday, Jun 13 2012, 16:33
Quote Post


Mark Chump
Group Icon
Group: Members
Joined: Apr 29, 2011

XXXXX



It's still displaying 0.
PM
  Top
 

 
Deji  
Posted: Wednesday, Jun 13 2012, 17:51
Quote Post


Coding like a Rockstar!
Group Icon
Group: Members
Joined: Dec 24, 2007

ja.gif

XXXXX



Well did you actually check the value was over 1.0 before the conversion?
Users WebsitePM
  Top
 

 
HeresOtis  
Posted: Wednesday, Jun 13 2012, 17:55
Quote Post


Mark Chump
Group Icon
Group: Members
Joined: Apr 29, 2011

XXXXX



Yea. This works properly, as it displays 175:
CODE
0653: 1@ = float_stat 24 // Player Max Health
1@ /= 5.69
0092: 1@ = float 1@ to_integer
01E4: show_text_1number_lowpriority GXT 'number' number 1@ time 5000 flag 1  // INSANE STUNT BONUS: $~1~


If I use a regular local variable then it's fine. But otherwise if I use the additional variable method, it doesn't. And I need the additional variables because I need to store more info in my script.
PM
  Top
 

 
Deji  
Posted: Wednesday, Jun 13 2012, 18:06
Quote Post


Coding like a Rockstar!
Group Icon
Group: Members
Joined: Dec 24, 2007

ja.gif

XXXXX



Additional vars can be awkward with some things. Why dont you swap some normal vars with some additional vars and use the normal vars for temporary storage?
Users WebsitePM
  Top
 

 

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)

0 Members:

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG