Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - Christopho

Pages: [1] 2 3 ... 68
It is a slight inacurracy that also exists in A Link to the Past.

Development / Re: How to get the hero in an item script?
« on: June 06, 2017, 10:39:13 am »
Code: Lua
  1. --slow the hero down
  2. function item:on_map_changed(map)
  3.   local hero = map:get_hero()
  4.   hero:set_walking_speed(30)
  5. end

Bugs & Feature requests / Re: "normal" video mode is at 2x
« on: June 05, 2017, 09:22:20 am »
Then it must be a bug.

Bugs & Feature requests / Re: "normal" video mode is at 2x
« on: June 03, 2017, 07:23:01 pm »
If you call, 240), it should work.

Bugs & Feature requests / Re: "normal" video mode is at 2x
« on: June 02, 2017, 09:50:39 am »
The x2 window scaling is just the default size of the normal video mode. You can always change that by calling

Development / Re: Get all map entities?
« on: June 01, 2017, 11:24:04 pm »
Well a movement can only have one direction at a time, so you have to choose a target.
You can always make a loop to detect the closest entity from a list of entities, and repeat this in a timer.

Development / Re: Screen vs entity position?
« on: May 15, 2017, 05:08:27 pm »
entity:get_position() give coordinates relative to the map. You can find coordinates relative to the screen if you just subtract the camera position.

Development / Re: pcall metatable?
« on: May 05, 2017, 02:05:09 pm »
Ok, so your question is actually independent from metatables or Solarus, it is about the passing a value of type function vs calling a function.
Code: Lua
  1. function metatable:example()
  2.   --some code
  3. end

This defines a field "example" (of type function) on the object "metatable", and not an "example" global value.

Which means that you can call it like this, assuming you  have an entity called my_entity:
Code: Lua
  1. my_entity:example()
and not like this
Code: Lua
  1. example() -- Does not work: example is nil

If you want to make a value of type function instead of doing the call entity:example(), just wrap the call it in a function:
Code: Lua
  1. local function f()
  2.   my_entity:example()
  3. end
Then it is a value of type function (and not a function call anymore, this is the trick!) so you can pass it to anything that wants a value of type function, like pcall, sol.timer.start, etc.
Code: Lua
  1. local success = pcall(f)
  2. if success then
  3.   ...
  4. else
  5.   ...
  6. end

You can even keep it anonymous if you prefer:
Code: Lua
  1. local success = pcall(function()
  2.   entity:example()
  3. end)
  4. if success then
  5.   ...
  6. else
  7.   ...
  8. end

Development / Re: pcall metatable?
« on: May 05, 2017, 11:21:31 am »
Your code is a correct way to catch errors.
But you were talking about metatables in your first message, what do you want to know exactly?

I don't know if it answers your question, but sol.main.get_metatable() returns nil if the parameter is an unknown type name. It will only throw an error if the parameter is missing or is not a string.

Development / Re: pcall metatable?
« on: May 05, 2017, 10:01:00 am »
What do you mean?

Development / Re: 2 Player
« on: May 02, 2017, 10:32:01 am »
For networking multiplayer, you don't need to change the C++ code of the engine. You can use a Lua networking library like LuaSocket. It is true that there is no direct networking support in the Solarus API yet: you will have to do a lot of things manually, but no C++.

Development / Re: Create a new "attack_consequence"
« on: April 28, 2017, 12:37:05 pm »
You can add your own attacks with scripts. Don't use enemy:set_attack_consequence(), but instead, define your own functions. This is what I do with several items like the hammer, the hookshot, etc.
See for example the hammer script here:
I create functions enemy:get_hammer_reaction(), enemy:set_hammer_reaction() and enemy:set_hammer_reaction_sprite(). Metatables are used so that all enemies have the new functions.

Development / Re: Freeze hero?
« on: April 27, 2017, 09:09:25 am »
I don't understand the question. You can call hero:set_animation() when the hero is frozen, there is no problem.

Your projects / Re: Zelda: Book of Mudora
« on: April 12, 2017, 09:02:12 am »
3) Just use a monospaced font and detect characters that use two bytes.

Your projects / Re: Zelda: Book of Mudora
« on: April 11, 2017, 10:59:09 pm »
Can you tell me again what was wrong and why detecting two-byte characters did not work?

Pages: [1] 2 3 ... 68