How can I use an item?(resorved)

U

uni00

Guest
When you get an item, add a picture of the item to dslist and put the item in your inventory. At the same time, add a variable that determines the usage of the item to another dslist.
Clicking on an item to remove it from the dslist will remove the item's picture.
At the same time, I decided to set the judgment variable to true and process the effect of the item with an if statement.
However, you cannot directly assign true to dslist. Error occurs
How can I use the item?
thanks
 

Attachments

Please copy and paste your actual code in between [ code] and [ /code] tags (with spaces removed) instead of screenshots. If you want to set position 0 in a ds_list to true, you can do it two ways. Using an "accessor" it's done like this:
Code:
itemeffect[| 0] = true; // This sets position 0 in the ds_list itemeffect to true
itemeffect[| 1] = true; // This sets position 1 in the ds_list itemeffect to true
Using GMS functions, it's this way:
Code:
ds_list_set(itemeffect,0,true); // This sets position 0 in the ds_list itemeffect to true
ds_list_set(itemeffect,1,true); // This sets position 1 in the ds_list itemeffect to true
 

Nidoking

Member
And don't delete the list entries, because that rearranges the list and the values won't line up anymore. If you want two lists that always have corresponding values, maybe consider using a grid instead.
 
U

uni00

Guest
And don't delete the list entries, because that rearranges the list and the values won't line up anymore. If you want two lists that always have corresponding values, maybe consider using a grid instead.
Thank you. This is my first time using a grid. Sounds difficult. .. ..
 

woods

Member
And don't delete the list entries, because that rearranges the list and the values won't line up anymore. If you want two lists that always have corresponding values, maybe consider using a grid instead.
using a grid. Sounds difficult. .. ..
isnt a grid basically two or more lists side by side? ...looking back to refresher's spreadsheet explanation ;o)
if that makes it any easier
 
U

uni00

Guest
Hmm. .. .. It is nice that you can display the acquired item in the inventory and click it to consume it, but it is meaningless unless the effect is reflected, it is difficult,
 
You can store a script in the grid alongside the other values for the item and use script_execute when clicking on an item to run that script. There's fancier ways to do it in 2.3, but since that's not out of beta yet, 2.2 methods will do for now.

Something like this:
Code:
grid[# 0,0] = sprite;
grid[# 0,1] = "Item Name";
grid[# 0,2] = script_name;
Then when you click on the item, get the item position in the grid and do this:
Code:
script_execute(grid[# item_position,2]);
 
U

uni00

Guest
You can store a script in the grid alongside the other values for the item and use script_execute when clicking on an item to run that script. There's fancier ways to do it in 2.3, but since that's not out of beta yet, 2.2 methods will do for now.

Something like this:
Code:
grid[# 0,0] = sprite;
grid[# 0,1] = "Item Name";
grid[# 0,2] = script_name;
Then when you click on the item, get the item position in the grid and do this:
Code:
script_execute(grid[# item_position,2]);
There's such a convenient function! !! Wow! Wow! !! !!
Thank you!
 

woods

Member
if you have [health_potion] in slot1 of the grid and [scr_drink_potion] in slot2 (i mean in the same row)
you would have a script named [scr_drink_potion ]

health potion count -= 1;
health += 50;


or something like that.. right?
 
Top