This didn't fix the problem,but it saved future ones,in almost every instance outside of these blocks where I use this list, I had it selecting the item on index 1 when trying to pick the enemy number, when it should have been index 2. I still believe that this is the cause of the problem but I can't find anywhere in the code where a third item is added in the list (the error show a list with three items)
Tl;dr
Can you provide a screenshot of the error?
Is it from @ABG 's screenshot?
If yes, search for replace list item in your blocks
Taifun
The error message is saying that the code tried to replace item 1 of non-list 0 with 0.
This sounds like another mis-dimensioned initialization of a list, like fire and confusion.
Either that or one of the awful default returns
P.S. show us where and how you Initialize global turn_order.
Pps. If you are going to return garbage for not found results, at least return unique garbage to help find the point of failure in the blocks.
I've lost myself in the brambles of this code too many times.
I recommend a controlled burn, and the services of a landscape planner.
Switch to a functional style, and use higher order data structures.
Like I said at the beggining of the post, I just started using app inventor. I have no idea what those things you said are. Should I just look them up and try to implement them or is there a specific block sequence you recommend?
As said before, all the turn related lists and variables (except the turn list from the blocks uploaded before) are in the calculate order procedure, as seen below. Also, the not found results are like that so that there are no errors in this screen if you hadn't visited the other screens before. I guess I can change some of them because of other insurances I put in, but it would be tedious, not really that helpfull since I think the problem is from another source and finally it might create more unforeseen problems in instances of having not visited the previous screens. If it is any help I can upload the .aia file that now contains any changes done since the begining of this post.
There are 11 replace list item blocks. I just made some changes to some of them and I am gonna test them out now, but I doubt that it solved the problem.
Witcher (1).aia (258.0 KB)
This is the updated file and below are the blocks I asked about earlier. Is there a reason the label isn't changed whenever an error happens?
That block only catches component errors, not native block errors.
Read the chapters on lists and procedures in the free book.
Your speed sorting should be applied to a table of (combatant,speed), not just to a list of speeds.
Think of a spreadsheet representing a combat sequence, hit by hit, move by move. What would be in the columns and rows, to show rounds of combat?
I have not seen any posts yet from you showing Do It results. Your blocks should look like a pin cushion with traces
Thanks for all the help but due to my studies I'll probably leave the project for now. When I find more free time again I intend to read these tips and try to continue the project while cleaning up the messy and convoluted parts. If the topic hasn't closed I'll return to post the results or (hopefully not) request more help. Thanks again and sorry if I wasted anyone's time.
This is a good sample project to show off table driven apps.
I started a creature sheet at
to help with land clearing around the combat setup code.
It's just a foundation, though.
Here's another step at whittling away the bloat in this project, by applying reusable code in procedures .
This next step is to load your Bestiary into a TinyDB NameSpace as Creature dictionaries.
Input is the CSV table of the Google Sheet from my prior post:
Bestiary
Creature,Class,TotalPoints,MinSpeed,MaxSpeed,MinStrength,MaxStrength,Image,Description
Ghoul,Necrophage,15,1,13,1,13,ghoul_by_reaper78.jpg,"The ghoul is a necrophage that nests outside cities and villages. They are known to scavenge for dead bodies and mostly cause problems only when near starvation. They also have enough intelligence to hunt near big cities so they can dig up cemeteries or finish off any bodies left by other monsters. They do not seem to have any specific weaknesses, but due to their frail build, they usually don't cause any problem even to the most inexperienced monster hunter."
Nekker,Ogroid,30,15,28,1,28,nekker_by_f1amdring.jpg,Nekkers are extremely common ogroids that mostly hunt as necrophages. Their high speed and tendancy of grouping together is the only saving grace for this mostly weak monster. Due to their existent but not high intelligence they can easily be triicked.
Drowner,Stalker,45,1,43,1,43,drowner_by_gothawolf.jpg,Drowners are stalking necrophages that originate from drowned humans. Despite that they can still reproduce and nest. They are usually found in swamps or beaches eating fish or stalking unfortunate passer-bys. Their aquatic nature makes them slightly weak to fire but they are resiliant enough to attack even when set ablaze.
Wraith,Specter,60,15,58,1,15,wraith_by_vonmquocthai.jpg,"Wraiths are specters of the unavenged. They roam around a place of specific interest to the spirit, like the spot of an improper burial or the scene of a murder. Their curse can be lifted but due to the death of their memories and their relative weakness a monster hunter usually has no physical or moral reason to do so."
Siren,Havrue,75,20,73,1,20,siren_wip_by_davesrightmind.jpg,"Sirens are a type of mermaid that have a unique taste for human flesh. Although they can live off local prey, they often go to human-inhabited beaches and lure unsuspecting victims with their hypnotic songs. They are weak to fire but their high intellect makes them unpredictable."
Werewolf,Cursed,90,30,88,1,30,werewolf_by_llirik_13.jpg,"Werewolves are cursed humans that have taken on the characteristics of wolves. Their high speed , power and animallistic instics make them tough opponents but an experienced witcher hunter should know how to defeat one."
Katakan ,Vampire,105,1,103,1,103,vampire_by_andimayer.jpg,"The Katakan is a form of Vampire that usually lives in isolation. Every so often they will go out to hunt, where they can slaughter dozens of humans to feast on their blood before hybernating. They are methodical attackers that gather their strength before unleashing rapid and strong attacks."
Griffon,Hybrid,120,1,60,1,118,griffin_by_scratcherpen.jpg,"Griffons are a hybrid of a lion and an eagle.These massive hunters usually nest in hills and mountains where they hunt for large livestock. Their bulky hide and massive muscle mass make them herculean obstacles for any monster hunter, but their lack of ground speed and knowledge of combat can be exploited by experienced hunters."
Leshen,Relict,135,1,50,1,50,the_leshen_by_polarwiesel.jpg,Leshens are woodland relicts that live in secluded forests. They mark their territory with shrines and then parasite off of the ecosystem. This unfortunatly leads to humans being cursed and killed by them but their strength means it is more often than not worth it to abandon a village before considering hunting down the monster.
Wyvern,Dragon,150,1,148,1,148,dragons_by_88grzes.jpg,"Wyverns are a rare type of dragon that few have witnessed long enough to specify their appearance and behaviour. It is considered natural that their size, strength, speed and strong scales makes them the apex predators of the land."
This is loaded into a separate TinyDB instance at Screen1 Initialize time on the first run.
I collected the rest of your Screen1 initialization into a separate procedure, to allow deferring its execution until all needed files have been loaded.
If I need more files loaded at startup, I would daisy chain the loads one after another's completion, and leave the remainder of the initialization to after the last file has been loaded.
This draggable and reusable procedure takes CSV table text, and loads it into a TinyDB instance, row by row, tag by tag.
Each row is stored into the TinyDB under the tag gotten from column 1 as a dictionary, with the column headers used as dictionary keys for each row's dictionary.
An extra attribute ORDER is added to preserve the initial row order from the input CSV text, in case the sort order is important. In the case of your Bestiary, I notice the sort order has the easiest creatures first. Without this ORDER attribute, it would be impossible to guess the original order.