ZenHAX

Free Game Research Forum | Official QuickBMS support | twitter @zenhax | SSL HTTPS://zenhax.com
It is currently Sat Sep 23, 2017 6:04 pm

All times are UTC




Post new topic  Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Tue Mar 14, 2017 7:56 am 
User avatar

Joined: Fri Aug 08, 2014 1:06 am
Posts: 326
Hi i am trying to read an integer and maintain a multiple of 4,
i need something like this but is invalid syntax in Quickbms
Code:
get var long
if var < 4
    var = 4
elif var > 4 and < 8
    var = 8
elif var > 8 and < 12
    var = 12
endif


Code:
elif var greater than this and less than this
    var equals this

so is there another way to put that so it works in a bms script?
thanks for any help! :)


edit
nevermind i found another way :D
Code:
get var long
xmath check "var % 4"
if check == 3
    math var + 1
elif check == 2
    math var + 2
elif check == 1
    math var + 3
endif


another shorter way :)
Code:
get var long
xmath check "var % 4"
if check != 0
    xmath var "var - check + 4"
endif


and even yet shorter way :)
Code:
get var long
math var x 4


Last edited by Acewell on Mon Apr 24, 2017 11:08 pm, edited 1 time in total.

Top
   
PostPosted: Tue Mar 14, 2017 9:39 am 
Site Admin
User avatar

Joined: Wed Jul 30, 2014 9:32 pm
Posts: 6692
Your original solution was ok except that you forgot to repeat "var" in the second check:
elif var > 4 and var < 8


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 2 posts ] 

All times are UTC


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Limited