Mike_1990
Apr 25, 2018, 12:09 PM
Could somebody skillful in scripting please help me with a scrip I'm working on?
I was thinking of making a shop in my levels, where you can browse items by pressing left and right. So I made a code that reads the input and stores integer depending on input and what item you're on (or so I thought). The problem is, as it is now, it cycles through items (just text right now) randomly. I know it's probably some stupid mistake but I'm not a programmer so...
Here's the code:
int shop_item;
void onPlayerInput(jjPLAYER@ player){
if (((player.yPos >= 42*32) && (player.yPos <= 44*32)) and ((player.xPos >= 146*32) && (player.xPos <= 148*32))){
if (jjKey[0x27] == true){
switch (shop_item){
case 0:
jjPlayers[32].showText("@@@@@Item1", STRING::SMALL);
shop_item = 1;
break;
case 1:
jjPlayers[32].showText("@@@@@Item2", STRING::SMALL);
shop_item = 2;
break;
case 2:
jjPlayers[32].showText("@@@@@Item3", STRING::SMALL);
shop_item = 3;
break;
case 3:
jjPlayers[32].showText("@@@@@Item4", STRING::SMALL);
shop_item = 4;
break;
case 4:
jjPlayers[32].showText("@@@@@Item5", STRING::SMALL);
shop_item = 5;
break;
case 5:
jjPlayers[32].showText("@@@@@Item1", STRING::SMALL);
shop_item = 1;
break;
}
}
if (jjKey[0x25] == true){
switch (shop_item){
case 0:
jjPlayers[32].showText("@@@@@Item1", STRING::SMALL);
shop_item = 1;
break;
case 1:
jjPlayers[32].showText("@@@@@Item5", STRING::SMALL);
shop_item = 5;
break;
case 2:
jjPlayers[32].showText("@@@@@Item1", STRING::SMALL);
shop_item = 1;
break;
case 3:
jjPlayers[32].showText("@@@@@Item2", STRING::SMALL);
shop_item = 2;
break;
case 4:
jjPlayers[32].showText("@@@@@Item3", STRING::SMALL);
shop_item = 3;
break;
case 5:
jjPlayers[32].showText("@@@@@Item4", STRING::SMALL);
shop_item = 4;
break;
}
}
}
}
I was thinking of making a shop in my levels, where you can browse items by pressing left and right. So I made a code that reads the input and stores integer depending on input and what item you're on (or so I thought). The problem is, as it is now, it cycles through items (just text right now) randomly. I know it's probably some stupid mistake but I'm not a programmer so...
Here's the code:
int shop_item;
void onPlayerInput(jjPLAYER@ player){
if (((player.yPos >= 42*32) && (player.yPos <= 44*32)) and ((player.xPos >= 146*32) && (player.xPos <= 148*32))){
if (jjKey[0x27] == true){
switch (shop_item){
case 0:
jjPlayers[32].showText("@@@@@Item1", STRING::SMALL);
shop_item = 1;
break;
case 1:
jjPlayers[32].showText("@@@@@Item2", STRING::SMALL);
shop_item = 2;
break;
case 2:
jjPlayers[32].showText("@@@@@Item3", STRING::SMALL);
shop_item = 3;
break;
case 3:
jjPlayers[32].showText("@@@@@Item4", STRING::SMALL);
shop_item = 4;
break;
case 4:
jjPlayers[32].showText("@@@@@Item5", STRING::SMALL);
shop_item = 5;
break;
case 5:
jjPlayers[32].showText("@@@@@Item1", STRING::SMALL);
shop_item = 1;
break;
}
}
if (jjKey[0x25] == true){
switch (shop_item){
case 0:
jjPlayers[32].showText("@@@@@Item1", STRING::SMALL);
shop_item = 1;
break;
case 1:
jjPlayers[32].showText("@@@@@Item5", STRING::SMALL);
shop_item = 5;
break;
case 2:
jjPlayers[32].showText("@@@@@Item1", STRING::SMALL);
shop_item = 1;
break;
case 3:
jjPlayers[32].showText("@@@@@Item2", STRING::SMALL);
shop_item = 2;
break;
case 4:
jjPlayers[32].showText("@@@@@Item3", STRING::SMALL);
shop_item = 3;
break;
case 5:
jjPlayers[32].showText("@@@@@Item4", STRING::SMALL);
shop_item = 4;
break;
}
}
}
}