Hi! I was trying to script a weapon menu like the one in Link's awakening (but with 3 slots and any weapon could be assigned to each of them). I wanted to make it possible to unassign the sword of the attack button (with the possibility of assigning other items to the attack button), but also I want the possibility of assigning the sword to other buttons, is it possible? The problem that I have is that I don't know how to start the built-in sword attack from an item script...
(Note that calling the command "game:simulate_command_pressed("attack")" is not a solution since the sword would be already unassigned from the attack command.)
Could this be possible with solarus 1.5 using some access to the sword sprite? And in that case how?
I guess that I will have to script my own sword as a custom entity instead of using the built-in one... :-\
I don't really know what you want to do ? You want to make the attack slot item-assignable ?
My though is to entirely code the sword in LUA and assign a savegame value to this slot (which will determine what item is assigned to this slot) and then, if the attack button is pressed, start the item.
Yes, I will have to use a custom entity for the sword. It's probably the best option.
Or you could make a New Item Like: Sword 2
and use a Code Like: set:asainable(true)
Would this help? https://github.com/christopho/solarus/issues/821
Hmmm, if the default sword script have hero:start_sword() in on_using, yes, this could save a lot of time.
Since what he wants is a item-assignable button, a single value (like I said) representing what is assigned might do what he wants.
Off topic : In the other hand, would it be possible f there are the same thing but for the spin attack ? (hero:start_spin_attack())
Thanks a lot Christopho! That would be exactly the solution I was looking for, so I will wait for it.
(Sorry if I am asking too many things and features, which could be annoying for the forums sometimes. It's because I have been scripting a lot lately and these kind of problems appear frequently...)
As MetalZelda suggests, it would be useful too to have a function "hero:start_spin_attack()".
A nice and general syntax for future versions could be a function "hero:start_attack(attack_name)".
Pros: shorter API and simpler functions.
Cons: incompatibilities with the current syntax, which is terrible...
Anyway, one could define that general function directly using the current ones, so it is not necessary.
hero:start_attack() is now done in 1.5 development version.
For the spin attack, we will see later how to remove it properly from the engine and replace it by a script. So since it will disappear, I am not adding spin attack things to the API.