How Does "else" work?

gukingofheart

Well-Known Member
OP
Member
Joined
Feb 2, 2022
Messages
235
Trophies
0
Age
124
XP
455
Country
United States
I tried two methods, and it's not working like I want.
If my life count is less than 4, give me fire power, ELSE give me cape & star item.
My code gives me cape & star no matter my life count.


Method 1
183042BC 00000004
00304300 00000003
00000000 40000000
00000000 60000000
00304300 00000002
00304301 00000003
00000000 00000000

Method 2
183042BC 00000004
00304300 00000003
00000000 60000000
00304300 00000002
00304301 00000003
00000000 00000000

"Execute all following codes
All following codes are executed regardless of anything else."

Is this saying, IF/Else don't work like that? if so, then what is the point of the Else statement?
 

TechieSaru

Well-Known Member
Newcomer
Joined
Mar 2, 2022
Messages
73
Trophies
0
Location
Somewhere, Out there
XP
852
Country
United States
There's no such thing as an "else" case when working with gameshark codes. Codes either are or aren't executed. To achieve what you want here, give the "give star and cape" the OPPOSITE condition of your original if; that is "lives > 4".

Also, you weren't clearing the item box.

Edit: Didn't realize that was a proper conditional. Disregard the bit about rom patch cheats.

Here is what you want:

Code:
183042BC 00000003 // If lives < 4
00304300 00000003 // Give mario fire flower
703042BC 00000002 // If lives > 3 (same as >= 4)
00304300 00000002 // Give mario a cape...
00304301 00000003 // AND set the box item to a star
583042BC 00000003 // If lives < 4...
08304301 00000003 // And if the item in the box is a star...
00304301 00000000 // Clear the item box

Notes: Type'70' is a two-line "if greater-than" and type '58' is a two-line "if less-than".
 
Last edited by TechieSaru,

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Xdqwerty @ Xdqwerty: https://youtu.be/8wi6dnzLcZ0?si=5zWGTK0CMXO3DJcb +2