Author Topic: Start the sword attack from an item script?  (Read 3904 times)

0 Members and 1 Guest are viewing this topic.

Diarandor

  • Hero Member
  • *****
  • Posts: 1062
  • Cats are cool! (ΦωΦ)
    • View Profile
Start the sword attack from an item script?
« on: January 10, 2016, 11:29:51 AM »
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?
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Diarandor

  • Hero Member
  • *****
  • Posts: 1062
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Start the sword attack from an item script?
« Reply #1 on: January 10, 2016, 11:58:45 AM »
I guess that I will have to script my own sword as a custom entity instead of using the built-in one...  :-\
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

MetalZelda

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
Re: Start the sword attack from an item script?
« Reply #2 on: January 10, 2016, 01:31:39 PM »
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.
« Last Edit: January 10, 2016, 01:37:18 PM by MetalZelda »

Diarandor

  • Hero Member
  • *****
  • Posts: 1062
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Start the sword attack from an item script?
« Reply #3 on: January 10, 2016, 02:00:46 PM »
Yes, I will have to use a custom entity for the sword. It's probably the best option.
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

GameboyArda

  • Jr. Member
  • **
  • Posts: 53
  • Solarus is awesome!
    • View Profile
    • Youtube
Re: Start the sword attack from an item script?
« Reply #4 on: January 10, 2016, 06:16:09 PM »
Or you could make a New Item Like: Sword 2

and use a Code Like:
Code: ( lua) [Select]
set:asainable(true)
You know that nearly all of use strugled once
with RPG maker. But now we make with
Solarus! 8)

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1190
    • View Profile
Re: Start the sword attack from an item script?
« Reply #5 on: January 10, 2016, 08:06:58 PM »

MetalZelda

  • Hero Member
  • *****
  • Posts: 551
    • View Profile
Re: Start the sword attack from an item script?
« Reply #6 on: January 10, 2016, 08:34:55 PM »
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())
« Last Edit: January 10, 2016, 08:36:26 PM by MetalZelda »

Diarandor

  • Hero Member
  • *****
  • Posts: 1062
  • Cats are cool! (ΦωΦ)
    • View Profile
Re: Start the sword attack from an item script?
« Reply #7 on: January 11, 2016, 01:56:13 AM »
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.
« Last Edit: January 11, 2016, 02:05:25 AM by Diarandor »
“If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you.”

Christopho

  • Administrator
  • Hero Member
  • *****
  • Posts: 1190
    • View Profile
Re: Start the sword attack from an item script?
« Reply #8 on: January 25, 2016, 12:43:05 PM »
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.