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.


Topics - llamazing

Pages: [1]
1
Bugs & Feature requests / Straight movement bug with set_max_distance?
« on: September 08, 2017, 07:31:41 am »
I'm trying to use a straight movement, and the straight_movement:set_max_distance(max_distance) function is not working the way that I'd expect.

Below is simplified code of what I am trying to do. At 4 seconds the table obj is moved 100 pixels to the right, and then 3 seconds after that it is moved 100 pixels to the left to return it to its original position.

The problem is that the set_max_distance function appears to be calculating the distance from (0,0), when I'd expect it to calculate the distance from what the coordinates were at the start of the movement. The result is that the second movement ends up being a 200 pixel movement to the left instead of the 100 pixels that I wanted (the object stops when x=-100, which is 100 pixels from (0,0)).

Code: Lua
  1. local obj = {x=0, y=0}
  2. sol.timer.start(4000, function()
  3.   print(obj.x) --0 at 4 seconds
  4.  
  5.   local movt1 = sol.movement.create"straight"
  6.   movt1:set_speed(100)
  7.   movt1:set_angle(0)
  8.   movt1:set_max_distance(100)
  9.   movt1:start(obj)
  10.  
  11.   function movt1:on_finished() print(obj.x) end --obj.x=100 at 5 seconds
  12.  
  13.   sol.timer.start(3000, function()
  14.     print(obj.x) --100 at 7 seconds
  15.    
  16.     local movt2 = sol.movement.create"straight"
  17.     movt2:set_speed(100)
  18.     movt2:set_angle(math.pi)
  19.     movt2:set_max_distance(100)
  20.     movt2:start(obj)
  21.    
  22.     function movt2:on_finished() print(obj.x) end --obj.x=-100 at 9 seconds; expected obj.x=0 at 8 seconds
  23.   end)
  24. end)

2
Your projects / Tech Demo using Cythera style interactive dialogs
« on: January 25, 2017, 09:13:09 am »
I'm not expecting anyone to have heard of the game Cythera, which is a mac exclusive tile from the late 90s. It had an interesting dialog system where certain words said by NPCs would be highlighted, and the player could ask about them go into more depth on that topic. I've discussed this type of dialog system previously in this topic.

I've put together a quick little sample quest that tries to replicate the dialog system used by Cythera. It replicates the dialog text of three characters from the game (one of which is fairly complicated and a good testbed to push my dialog script to its limits).

When talking to NPCs, pretty much all of them respond to the key words "name", "job" and "bye" (to close the dialog). Beyond that, certain key words are highlighted in blue denoting that the player can take the conversation further by asking about those topics. The player can either type the keyword into a text box or select them from a running list by using the mouse.

A little quirk to be aware of is that only the first 5 letters of whatever the player types in are considered (it can be less than 5 letters too, depending on the word). This makes it easy for "fish", "fishing" or "fisherman" to all give the same response. Note that while Cythera only ever considered the first 4 letters entered, I decided to bump the limit up to 5 for a little more versatility. I don't think that it would ever be necessary to use more than 5 letters, though.

See if you can figure out how to complete this short little quest. I will say that there are two possible solutions. No items are required, and there are not any enemies.

Installation instructions:
The Solarus ALTTP resource pack is required for this quest. Confirmed to work with version 1.5.6, which can be found here. Download and extract the ALTTP resource pack. Then download my quest and extract it to the the same directory as the resource pack. For any duplicate files between the two, the ones from my quest should overwrite the ones from the resource pack.

Feel free to borrow and or modify the scripts for your own usage. Note that most of the images and sounds included in the quest actually come from Cythera and should not be used. If I end up going further with this project, it will ultimately not use any Cythera assets or text.

This demo quest has the following features:
  • Interactive dialog system
    • NPC portraits
    • clickable hyperlink text
    • text input
    • dynamic dialog content that depends on a multitude of factors
  • Preserve a log of NPC dialog for later reference
  • Objective tracking
  • Day/night cycle that darkens the map at night
    • lluminating light sources at night
    • Different music between night & day
    • NPC movements synchronized with the time
    • sleep in a bed to advance time
  • Read-only console that prints notifications for the player
  • Various UI elements with mouse/keyboard interaction

The quest can be downloaded from its github project page

3
Development / Pickable Item with No Shadow (Solved)
« on: December 25, 2016, 12:02:10 am »
Using the ALTTP resource pack, I wanted to create a pickable treasure for the bottle, which looks bad if it has a shadow.

According to the Equipment Items documentation, the method item:set_shadow(shadow_animation), where shadow_animation is nil gives no shadow. However, when I try doing item:set_shadow(), I get the following error:

Error: In on_created: [string "items/bottle_1.lua"]:9: bad argument #1 to set_shadow (string expected, got no value))

I also tried item:set_shadow(false) and item:set_shadow("nil") to no avail. What am I doing wrong here?

4
Development / Clear contents of Quest Editor console?
« on: December 04, 2016, 10:16:36 am »
Is there a way to clear what's displayed in the console of the Quest Editor? When there are a bunch of errors that I've fixed by editing my scripts, it would be nice to reset the console to a blank slate before running the quest again in order to verify the fix.

I checked the menus and right-click pop-up menu but didn't see anything to clear the contents of the console. I'm wondering if maybe there is a command that can be typed into the console to clear it?

5
Development / Getting the sprite of a Dynmaic Tile
« on: September 25, 2016, 08:31:09 pm »
I have a tile that I converted to a dynamic tile (pattern torch_big.top from the ALTTP resource pack), but when I call get_sprite() for the dynamic tile from in the map:on_draw() function, it returns nil. What am I doing wrong?

What I want to do is read the frame number so that I can synchronize an overlay with the animation.

6
Development / NPC movement paths and obstacle detection
« on: September 23, 2016, 10:44:15 pm »
I've been playing around with assigning path movements to npcs in order to have them follow a fixed route. The problem I'm running into is obstacle avoidance. Now it's easy enough to choose a route for the NPC that is clear of obstacles on the map, and I'd only have the NPCs moving around inside of towns where there are no enemies, so collisions with enemies are not a concern either. It's just collisions with the hero that I have to worry about.

I started off by setting set_ignore_obstacles(true) for the NPC movement. For the most part, that works. If the NPC's path goes through the hero's position then the hero will just get stuck for a little while until the NPC passes the hero, and it's just a little annoyance. The problem occurs if the hero happens to be standing where the NPCs path stops (and the NPC just stands in that spot for a while). Now the hero cannot move at all until the NPC starts a new path movement.

So then I played around with trying to push the hero out of the way when there's a collision with the NPC. So in the NPC movement's on_position_changed() function (any time the NPC moves), I check if the NPC and hero overlap with NPC:overlaps(hero, "overlapping"), and if they do, I assign a movement to the hero to nudge the hero out of the NPC's path.

I'm assuming that I need to move the hero one pixel at a time so that if the hero gets pushed over a 16x16 teletransporter (say inside a doorway), that the hero doesn't get pushed too far and skip the teletransporter. Is that correct? Pixel movement also seems preferable over path movement so that the hero can be moved just a couple pixels out of the way of the NPC instead of multiples of 8 pixels.

So I got something setup to move the hero when an NPC walks into him, but now I'm running into problems with making sure the hero doesn't get pushed into an obstacle when nudged. As an example, consider an NPCs walking along a path in the North direction with the Hero to the North of the NPC. When a collision occurs, I want to nudge the hero to the NW because if I only nudge the hero N, then the NPC could end up pushing the hero for the entire length of the path.

To nudge the hero to the NW, I give the hero's pixel movement a trajectory with several entries of {-1, -1}. The problem now is if there is an obstruction on the map to the west of the hero, I still want the hero to be moved to the N. It seems the hero's movement just calls on_obstacle_reached() and doesn't move the hero at all, even though there is no obstacle to the North.

The workaround I then used for the above problem is to give a trajectory that only moves one pixel W then one pixel N, alternating (i.e. {{-1,0}, {0,-1}, {-1,0}, {0,-1}...etc.}). This actually works for the most part, but there are still a few corner cases that don't quite work.

See the example image below, where the green 16x16 box is the hero, the blue is the npc, who is walking to the north to the doorway in the building above. The grey pixels (and the doorway) are traversable. So then the first time the NPC and hero bounding boxes overlap, there are six pixels (cyan) where the overlap occurs. Now obviously nudging the hero to the north fails because there is a building in the way, but nudging the hero to the east also fails because if the hero is moved 1 pixel to the east, the hero still overlaps the NPC by 5 pixels.

I don't have a good solution to this problem. The only thing I can think of is to do set_ignore_obstacles(true) for the hero and do my own manual obstacle detection, but that's tricky because it runs the risk of pushing the hero into the side of a building and getting stuck. I'm assuming I'd have to use map:get_ground() to do my own collision text, but how does that work? With a "wall_top_right" tile, for example, the bottom left corner of the tile is traversable and the top right corner is not. So does that mean that a coordinate in the top right half of the tile returns "wall_top_right" whereas a coordinate in the bottom left half of the tile returns "traversable"?

Or does anyone have any better ideas?

7
Development / Pattern matching and UTF-8
« on: September 08, 2016, 02:47:52 am »
I'm working on a custom dialog manager script for the features I described in this topic. A few questions have arisen in the process regarding UTF-8 characters:

1) In the text of my dialogs.dat file, keywords are denoted by prefacing the keyword with the "@" character. My original concept was to iterate through the keywords in the text using the following:
Code: [Select]
text:gmatch("@(%w+)")which works great for ASCII text and forces keywords to only be alpha-numeric characters. However, my limited testing seems to conclude that it will not work as intended if UTF-8 characters are used.

It looks like a better solution is to instead use the following:
Code: [Select]
text:gmatch("@([^%p%s]+)")which grabs all characters between the @ character and the first punctuation or space character (it only looks at one line at a time, so new-line characters are excluded).

Am I correct that pattern matching doesn't work with UTF-8 characters, and is my second proposed solution viable for when UTF-8 characters are used?

2) I also convert the text input of the player (in their native language) to lowercase with string.lower() so that case does not matter. My testing seems to indicate that string.lower() does not do anything for UTF-8 characters, but I see a note in the lua manual for the string.lower() entry that it depends on the locale.

How does the locale affect string.lower() and is the locale set automatically by the Solarus engine? Or perhaps by the operating system?

3) I've noticed that string.len() doesn't work the way I want it to in regard to UTF-8 (multibyte) characters since it returns the number of bytes in the string, and not the number of actual characters. It's easy enough to write my own custom function to count the number of characters in a string, but I figure I may as well ask...

Are there any included lua functions in the Solarus engine that return the number of characters in a string? It looks like lua 5.3 might have support for that, but as far as I can tell, Solarus appears to be using lua 5.1.

8
Development / Getting all strings in strings.dat?
« on: September 04, 2016, 06:22:04 pm »
It there a good way to either get all key/value entries in strings.dat for a given language or just the ones with keys beginning with a certain pattern?

Or do I have to parse strings.dat in my own script to extract the info myself?

I was trying to manually keep a list of strings.dat keys I'm interested in, but there's too many and it's becoming too much of a hassle.

Pages: [1]