Holy lord, there's so many features!
A Crafting System should be easy to implement with a little skill. I already have one going to be in place in my game. I call it a Tradeskill system because it goes by levels and exp to determine what you can make. If you're interested in that, I have a Tech Demo out that demonstrates it.
Oh, sweet! That'll give me a good starting point to go about figuring out how to implement the crafting system I want. Thanks loads for the heads up! Cheers!
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
OK, I'm stumped. I can't quite figure out just what I'm doing wrong:
This is used to populate a menu with all the items in the inventory. During crafting, this menu is presented three times (Or perhaps three of them are side by side? I'm not quite sure yet) to allow the player to select three items. What three items are selected, will be stored, then checked against a list of possible combinations. Something like the Horadric cube of Diablo II, where the game doesn't outright give you recipes, and you have to either experiment to get them, or find some in-game "cookbooks" of sorts.
Problem is, this part right here is currently stumping me, I can't get the menu to populate correctly, gah! I did come across this and thisthough. Does that mean that I can't currently do what I'm planning?
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Code:
plotscript, craftingmenu, begin
variable(counter, itemhandle, maxitems)
trace value(get inventory size)
maxitems := get inventory size
for(counter, 1, max items -- 1) do( #Cycle through all the items in the inventory
if(item in slot(counter) >> 0) then( #If there actually is an item in this slot, do the following
trace value(item in slot(counter))
trace value(get item name(1,counter))
itemhandle := add menu item(menu:Crafting) #Add a new menu item to the crafting menu
get item name(1,counter) #Get the name of the above item
set menu item caption(itemhandle, 1) #Set the caption of this menu item to the name of the inventory item
)
)
open menu(menu:crafting,FALSE) #Open up the menu
end
variable(counter, itemhandle, maxitems)
trace value(get inventory size)
maxitems := get inventory size
for(counter, 1, max items -- 1) do( #Cycle through all the items in the inventory
if(item in slot(counter) >> 0) then( #If there actually is an item in this slot, do the following
trace value(item in slot(counter))
trace value(get item name(1,counter))
itemhandle := add menu item(menu:Crafting) #Add a new menu item to the crafting menu
get item name(1,counter) #Get the name of the above item
set menu item caption(itemhandle, 1) #Set the caption of this menu item to the name of the inventory item
)
)
open menu(menu:crafting,FALSE) #Open up the menu
end
This is used to populate a menu with all the items in the inventory. During crafting, this menu is presented three times (Or perhaps three of them are side by side? I'm not quite sure yet) to allow the player to select three items. What three items are selected, will be stored, then checked against a list of possible combinations. Something like the Horadric cube of Diablo II, where the game doesn't outright give you recipes, and you have to either experiment to get them, or find some in-game "cookbooks" of sorts.
Problem is, this part right here is currently stumping me, I can't get the menu to populate correctly, gah! I did come across this and thisthough. Does that mean that I can't currently do what I'm planning?
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
You provided lots of information about what you are trying to do, but no information at all about how exactly it fails.
However, reading over your code, I think I can see the problem. You are using a menu ID where you are supposed to be using a menu handle. There are only a handful of commands that use menu IDs ("open menu" and "find menu" are the only ones that I can think of off the top of my head.)
Am I correct to assume that the menu named menu:Crafting is completely blank? If so, you should just use the "create menu" command instead
Code:
add menu item(menu:Crafting)
add menu item(menu:Crafting)
However, reading over your code, I think I can see the problem. You are using a menu ID where you are supposed to be using a menu handle. There are only a handful of commands that use menu IDs ("open menu" and "find menu" are the only ones that I can think of off the top of my head.)
Am I correct to assume that the menu named menu:Crafting is completely blank? If so, you should just use the "create menu" command instead
Ah, crikey, I forgot to explain how it fails, silly, silly BMR!
The error I get is: "invalid menu handle -1" which shows up once I try to activate craftin in-game.
Yes, menu:Crafting is blank. I'll give using "create menu" a shot then, thanks!
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
The error I get is: "invalid menu handle -1" which shows up once I try to activate craftin in-game.
Yes, menu:Crafting is blank. I'll give using "create menu" a shot then, thanks!
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Anytime you get an error that reads "invalid ______ -1", it generally means that the thing you were trying to refer to doesn't exist (and hence the reference to it returns -1). Like if you try to refer to the hero in slot 2 when the player has actually moved any heroes out of slot 2, game.exe will return a similar error. Just a random tip that may help you debugging in the future.
SPELLSHARD: THE BLACK CROWN OF HORGOTH now COMPLETE! Grab it today!
SPELLSHARD: THE BLACK CROWN OF HORGOTH now COMPLETE! Grab it today!
Excellent! Populating menus works now:
I decided to go with not using "create menu" though, as some of the items on the menu will always be the same, so rather than always generating them I'll keep them in custom menus.
Thanks!
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Code:
plotscript, craftingmenu, begin
variable(counter, itemhandle, menuhandle, maxitems)
trace value(get inventory size)
maxitems := get inventory size
menuhandle := open menu(menu:crafting,FALSE)
for(counter, 1, max items -- 1) do( #Cycle through all the items in the inventory
if(item in slot(counter) >> 0) then( #If there actually is an item in this slot, do the following
trace value(item in slot(counter))
trace value(get item name(1,counter))
itemhandle := add menu item(menuhandle) #Add a new menu item to the crafting menu
get item name(1,counter) #Get the name of the above item
set menu item caption(itemhandle, 1) #Set the caption of this menu item to the name of the inventory item
)
)
end
variable(counter, itemhandle, menuhandle, maxitems)
trace value(get inventory size)
maxitems := get inventory size
menuhandle := open menu(menu:crafting,FALSE)
for(counter, 1, max items -- 1) do( #Cycle through all the items in the inventory
if(item in slot(counter) >> 0) then( #If there actually is an item in this slot, do the following
trace value(item in slot(counter))
trace value(get item name(1,counter))
itemhandle := add menu item(menuhandle) #Add a new menu item to the crafting menu
get item name(1,counter) #Get the name of the above item
set menu item caption(itemhandle, 1) #Set the caption of this menu item to the name of the inventory item
)
)
end
I decided to go with not using "create menu" though, as some of the items on the menu will always be the same, so rather than always generating them I'll keep them in custom menus.
Thanks!
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Success! Crafting now works, for the most part, bug-freely. Not perfectly, and not completely, but the bare-bones part is up and running.
The code I came up with in the end is:
So the way crafting works is, when the player brings up the crafting menu (That part I haven't figured out yet, in terms of how to do it in-game. Restrict crafting to "tool-benches"? Crafting is possible wherever the player is? Not sure yet.) which looks like this:
The list is populated by all the items that the player has in his inventory. If there's more than one copy of the item, it shows up twice, or thrice, or whatever. My problem here is that once the player gets a lot of items, this list may become rather cumbersome to have to scroll through. Upon selecting items, those items are removed from the list. That way, it's not possible to select an item three times when you only have two of that item.
Once three (all recipes have three ingredients) items have been chosen, the menu closes, and the script looks up the items that were chosen in the recipe script. Right now, the order of items actually matters. So (Item A, Item B, Item C) will produce a result, but (Item B, Item A, Item C) will not, even though it's essentially the same thing. I'm thinking if I should remedy this, or explain it in-game, that items have to be added in a specific order for the magic to work. Kind of like in cooking, you don't add your veggies before you add your meat. Well, you could, but you'd get soggy veggies.
If the script finds that there's a corresponding recipe, it removes the used ingredients from the player's inventory. It will then add a new item to the player's inventory. If there is no corresponding recipe, then nothing will happen, no items are removed, and the player is only penalized with a sense of frustration at not getting the recipe right.
For the recipes, I have a spreadsheet where I just input the three items and the final item. It's all concatenated into a single cell that I can copy to my script.
My worries are that this will get a bit too cumbersome in terms of memory. Would having this massive list slow things down? Or is it negligible? Anywho, that's all from me for now, cheers!
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
The code I came up with in the end is:
Code:
plotscript, craftingmenu, begin
variable(counter, counter2, maxitems, inventoryitem, inventorynumber)
trace value(get inventory size)
maxitems := get inventory size
menuhandle := open menu(menu:crafting,FALSE)
for(counter, 0, max items -- 1) do( #Cycle through all the items in the inventory
inventoryitem := item in slot(counter)
if(inventoryitem >> 0) then( #If there actually is an item in this slot, do the following
inventorynumber := inventory(inventoryitem)
for(counter2, 1, inventorynumber) do(
itemhandle := add menu item(menuhandle) #Add a new menu item to the crafting menu
get item name(1,inventoryitem) #Get the name of the above item
set menu item caption(itemhandle, 1) #Set the caption of this menu item to the name of the inventory item
set menu item type(itemhandle, menutype:script) #Set the item to have a script
set menu item subtype(itemhandle, @craftingchoosemenuitem)
)
)
)
end
script, craftingchoosemenuitem, begin
itemhandle := selected menu item(menuhandle)
get menu item caption(itemhandle, 1)
trace value(craftingstage)
trace value(craftingitem01)
trace value(craftingitem02)
trace value(craftingitem03)
switch(craftingstage) do(
case(1) do(
craftingitem01 := returnitemcode
increment(craftingstage, 1)
)
case(2) do(
craftingitem02 := returnitemcode
increment(craftingstage, 1)
)
case(3) do(
craftingitem03 := returnitemcode
increment(craftingstage, 1)
)
)
delete menu item(itemhandle)
if(craftingstage >= 4) then( close menu(menuhandle), recipes )
end
script, returnitemcode, begin
variable(counter)
for(counter, 1, 501) do(
get item name(2,counter)
if( string compare(1, 2) == TRUE) then(
return(counter)
)
)
end
script, recipes, begin
variable(success, successitem)
craftingstage := 1
success := FALSE
if(craftingitem01 == item:WkFire˙ && craftingitem01 == item:WkFire˙ && craftingitem01 == item:WkFire˙) then(
success := TRUE
successitem := item:AvFire˙
)
if(success == TRUE ) then(
get item name(3, successitem)
get item(successitem,1)
delete item(craftingitem01)
delete item(craftingitem02)
delete item(craftingitem03)
show text box(2236)
wait for text box
)
else
(
show text box(2237)
wait for text box
)
end
variable(counter, counter2, maxitems, inventoryitem, inventorynumber)
trace value(get inventory size)
maxitems := get inventory size
menuhandle := open menu(menu:crafting,FALSE)
for(counter, 0, max items -- 1) do( #Cycle through all the items in the inventory
inventoryitem := item in slot(counter)
if(inventoryitem >> 0) then( #If there actually is an item in this slot, do the following
inventorynumber := inventory(inventoryitem)
for(counter2, 1, inventorynumber) do(
itemhandle := add menu item(menuhandle) #Add a new menu item to the crafting menu
get item name(1,inventoryitem) #Get the name of the above item
set menu item caption(itemhandle, 1) #Set the caption of this menu item to the name of the inventory item
set menu item type(itemhandle, menutype:script) #Set the item to have a script
set menu item subtype(itemhandle, @craftingchoosemenuitem)
)
)
)
end
script, craftingchoosemenuitem, begin
itemhandle := selected menu item(menuhandle)
get menu item caption(itemhandle, 1)
trace value(craftingstage)
trace value(craftingitem01)
trace value(craftingitem02)
trace value(craftingitem03)
switch(craftingstage) do(
case(1) do(
craftingitem01 := returnitemcode
increment(craftingstage, 1)
)
case(2) do(
craftingitem02 := returnitemcode
increment(craftingstage, 1)
)
case(3) do(
craftingitem03 := returnitemcode
increment(craftingstage, 1)
)
)
delete menu item(itemhandle)
if(craftingstage >= 4) then( close menu(menuhandle), recipes )
end
script, returnitemcode, begin
variable(counter)
for(counter, 1, 501) do(
get item name(2,counter)
if( string compare(1, 2) == TRUE) then(
return(counter)
)
)
end
script, recipes, begin
variable(success, successitem)
craftingstage := 1
success := FALSE
if(craftingitem01 == item:WkFire˙ && craftingitem01 == item:WkFire˙ && craftingitem01 == item:WkFire˙) then(
success := TRUE
successitem := item:AvFire˙
)
if(success == TRUE ) then(
get item name(3, successitem)
get item(successitem,1)
delete item(craftingitem01)
delete item(craftingitem02)
delete item(craftingitem03)
show text box(2236)
wait for text box
)
else
(
show text box(2237)
wait for text box
)
end
So the way crafting works is, when the player brings up the crafting menu (That part I haven't figured out yet, in terms of how to do it in-game. Restrict crafting to "tool-benches"? Crafting is possible wherever the player is? Not sure yet.) which looks like this:
The list is populated by all the items that the player has in his inventory. If there's more than one copy of the item, it shows up twice, or thrice, or whatever. My problem here is that once the player gets a lot of items, this list may become rather cumbersome to have to scroll through. Upon selecting items, those items are removed from the list. That way, it's not possible to select an item three times when you only have two of that item.
Once three (all recipes have three ingredients) items have been chosen, the menu closes, and the script looks up the items that were chosen in the recipe script. Right now, the order of items actually matters. So (Item A, Item B, Item C) will produce a result, but (Item B, Item A, Item C) will not, even though it's essentially the same thing. I'm thinking if I should remedy this, or explain it in-game, that items have to be added in a specific order for the magic to work. Kind of like in cooking, you don't add your veggies before you add your meat. Well, you could, but you'd get soggy veggies.
If the script finds that there's a corresponding recipe, it removes the used ingredients from the player's inventory. It will then add a new item to the player's inventory. If there is no corresponding recipe, then nothing will happen, no items are removed, and the player is only penalized with a sense of frustration at not getting the recipe right.
For the recipes, I have a spreadsheet where I just input the three items and the final item. It's all concatenated into a single cell that I can copy to my script.
My worries are that this will get a bit too cumbersome in terms of memory. Would having this massive list slow things down? Or is it negligible? Anywho, that's all from me for now, cheers!
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Looks good. I wouldn't worry about speed, but I'll note that it's much simpler to store the item ID in a menu item extra data slot (setmenuitemextra, getmenuitemextra) instead of checking the menu item's caption.
Also, you can write "craftingstage += 1" instead of "increment(craftingstage, 1)"
You created a spreadsheet to generate script statements? I'm impressed! And generating textboxes? Wow. Wouldn't it be simpler to embed randomly generated strings in a textbox?
It's actually a minor bug that the error message often contains "-1" instead of the actual value you passed in. I hope to provide much more helpful error messages in the future.
Also, you can write "craftingstage += 1" instead of "increment(craftingstage, 1)"
Quote:
It's all concatenated into a single cell that I can copy to my script.
You created a spreadsheet to generate script statements? I'm impressed! And generating textboxes? Wow. Wouldn't it be simpler to embed randomly generated strings in a textbox?
Harlock Hero wrote:
Anytime you get an error that reads "invalid ______ -1", it generally means that the thing you were trying to refer to doesn't exist (and hence the reference to it returns -1).
It's actually a minor bug that the error message often contains "-1" instead of the actual value you passed in. I hope to provide much more helpful error messages in the future.
TMC wrote:
Looks good. I wouldn't worry about speed, but I'll note that it's much simpler to store the item ID in a menu item extra data slot (setmenuitemextra, getmenuitemextra) instead of checking the menu item's caption.
Huh, now why didn't I do that, it is indeed much easier and simpler. I shall rework the scripts to use those instead.
TMC wrote:
Wouldn't it be simpler to embed randomly generated strings in a textbox?
It would, but for some items, I have blurbs about the history of the world, religion, classes, etc... For the ones that were generated (i.e. Names and times of inn patrons) I was thinking of using strings to do that, but I was concerned that with the amount of data I have going through the scripts, the text wouldn't remain the same once I ran out of strings, but perhaps I may just be reading the string limitations incorrectly. Still, I suppose it would be a more elegant solution, having all those text-boxes generated just seems rather barbaric to me, hehehe. And it grates against my desire for efficiency in my code.
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
I haven't looked at the script yet, but what happens if the player hits ESC? Does it back out just one item, or the entire process? It might also be helpful if, after choosing the third item, the player is offered a confirmation choice (in case they accidentally picked the wrong item as their third item).
I am Srime
I am Srime
BMR wrote:
I was thinking of using strings to do that, but I was concerned that with the amount of data I have going through the scripts, the text wouldn't remain the same once I ran out of strings, but perhaps I may just be reading the string limitations incorrectly.
I'm not sure what you mean. The only limit on the number of string constants that you can place in a single script is the limit on the total (compiled) size of a script, which is 256kB. That's, I'd guess, about 50 pages of text.
There are 100 embeddable strings (raised in recent nightlies from 32)
Huh, I hadn't thought of that. Hmm... I guess pressing ESC could potentially break the script. And a confirmation choice would be a good idea, I shall add it, thanks!
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
OK... Now I'm just going to be silly...
Is there an easy way to import 1,814 screens into Custom in one go? These movies can be a bit cumbersome, hehe...
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl
Is there an easy way to import 1,814 screens into Custom in one go? These movies can be a bit cumbersome, hehe...
Being from the third world, I reserve the right to speak in the third person.
Using Editor version wip 20170527 gfx_sdl+fb music_sdl



