Editing default values

Started by Slicky, August 13, 2016, 03:43:59 AM

Previous topic - Next topic
Hey everyone, I am having some trouble location certain code that will allow me to change default values. Some of the values I'm looking for include default player speed(I know how to change it depending on the map, i just wanna know where you can just edit it overall), input commands(like why is c always attack and d pause, I see that it is saved in the save file, but I don't know how to edit prior to saving), and how to edit or add abilities. The reason for the last one is I am planning on having an ability for my player to throw his weapon and I was able to make a new item to do that, but I want it so that instead of collecting an item, he just starts with this ability or maybe obtains this ability at some point during the game. Thank you guys for all of your help!

Hi! All your problems can be solved with certain functions that you will find in the Lua API of Solarus with all the explanations you need.

For the keys you can use game:set_command_keyboard_binding(command, key).

To change the default walking speed for all the game you can do it in your game_manager script (or maybe in your main script), probably inside the event game:on_started(), by using hero:set_walking_speed(speed).

Items are not necessarily obtained as pickables. The "item" entities are just an abstraction that can be used for many purposes. You can use item:get/set_savegame_variable functions to set/get the variable where you save the possession state and then use game:get_value(variable) to know its value, etc.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Thanks so much for your help! So is there no way to edit or add to the existing built-in abilites like "sword", "sword_knowledge", "swim", etc..?

There are functions to add or remove built-in abilities. Check the functions game:get/set_ability in the API, etc.
"If you make people think they're thinking, they'll love you. But if you really make them think, they'll hate you."

Oh okay I get it. So if I'm correct, there are certain things in the game that you can't directly edit, but that you can call separate functions to edit. I think this has been what's confusing me. So like you can't edit directly where the character speed is set by default, but the only way to change it is to call a new function overwriting it.

Well now I am stuck again. Is it not possible to add your own ability or keyboard command? I am trying to make a default ability of being able to throw your weapon. I want this ability to be gained when the player gets his weapon, along with the normal sword ability which allows him to attack with it. This also requires having a new bound key to be used specifically for throwing the weapon. Sorry if I am just missing something, but I'm really stuck on this.

It is possible to make custom weapons additionally to built-in abilities. You just have to program it yourself in an item script or from the game:on_key_pressed() event.

Awesome Thank you! Is their anyway to view the code of the built in abilities or items for reference? I am a pretty entry level programmer and it would nice to see how the items work like the boomerang to help me with what I am doing.

Everything is open-source so yes, but built-in items are programmed in C++ so I am not sure if it will help a lot. You should rather look at item scripts in Zelda Return of the Hylian SE, there are good example of scripted items like the hammer and the hookshot.