Implement lua functions needed for Empire scenario 3

Bug #1675179 reported by hessenfarmer on 2017-03-22
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Undecided
Unassigned

Bug Description

while developing the scenario "Neptune's revenge" to eventually be mission number 3 in the empire campaign I realized that it would be helpful to have 2 new functions currently not part of the lua documentation / implementation.
1. A functionality to reinstate the complety black "fog of war" of a totally undiscovered field on the map. Currently there is only a funtion "hide_fields" which is hiding all activity on the map while still showing the map details seen last time. (this seems to be normal fog of war behaviour)
2. A lua function to check the target quantity of a specific ware in the economy options window would allow for a new type of mission objectives.

Related branches

GunChleoc (gunchleoc) on 2017-03-23
Changed in widelands:
milestone: none → build20-rc1
status: New → Confirmed
tags: added: campaign lua
Changed in widelands:
assignee: nobody → GunChleoc (gunchleoc)
TiborB (tiborb95) wrote :

I noticed that we dont have object for economy and the stuff in point 2 is related to economy, not the player. Do you plan to introduce such LUA object?

GunChleoc (gunchleoc) wrote :

If necessary, yes. I haven't looked at the code at all yet.

GunChleoc (gunchleoc) wrote :

@hessenfarmer: Could you please describe more fully what you need for 2? What would the player instructions be, how would the objective be resolved? Do you need to do something with the actual window, or do you just need to read the value from the economy?

GunChleoc (gunchleoc) wrote :

Hide fields is done (see attached branch). You can add it to your branch like this:

    bzr merge lp:~widelands-dev/widelands/bug-1675179-lua-hide-fields
    bzr commit -m "<your commit message>"

GunChleoc (gunchleoc) on 2017-03-26
summary: - missing/new lua functions
+ Implement lua functions needed for Empire scenario 3
kaputtnik (franku) wrote :

It would be nice to have a function to hide the mouse pointer or automatically hide it when scroll_to_filed() is executed. Especially when the whole screen is black and the map scrolls to a new area on the map, the mouse pointer 'suddenly' moves away. If it is hidden, the map move would be hidden also, the scrolling get unnoticed to the user.

New wishlist?

GunChleoc (gunchleoc) wrote :

Yes, new bug please.

kaputtnik (franku) wrote :
kaputtnik (franku) wrote :
GunChleoc (gunchleoc) wrote :

I think the random looks really good - it's taking too long for the second bit though. Try from the inside out, in a circular pattern?

kaputtnik (franku) wrote :

Circular revealing is easy to do:

function concentric_reveal(plr, center, amount, delay)
   if not delay then delay = 50 end
   local steps = 1
   while steps < amount do
      plr:reveal_fields(center:region(steps))
      steps = steps + 1
      sleep(delay)
   end
end

But for a 'concentric hide' i have no idea so far.

kaputtnik (franku) wrote :
kaputtnik (franku) wrote :

Don't know if it is part of this change, but if the buildhelp is toggled on, the flags and buildings space is shown on the black background.

GunChleoc (gunchleoc) wrote :

Looks like it is a bug in the new hide function - I didn't test it on territory owned by the player.

kaputtnik (franku) wrote :

# Looks like it is a bug in the new hide function

I think this has never come up until the new hide function was implemented. So it's not a bug in your code. Just found: We can set the buildhelp off/on with lua already:
https://wl.widelands.org/docs/wl/autogen_wl_ui/#wl.ui.MapView.buildhelp
So nothing to change in this branch, except:

To make the animations more smooth, maybe there could be lua access (read/write) to the revealed but unseen state of a field (the state a field is revealed but not seen by a building or worker).

There are already two functions which are read only for getting the state, but not for setting:

player:sees_field
player:seen_field

https://wl.widelands.org/docs/wl/autogen_wl_game/#wl.game.Player.sees_field
https://wl.widelands.org/docs/wl/autogen_wl_game/#wl.game.Player.seen_field

GunChleoc (gunchleoc) on 2017-04-20
Changed in widelands:
status: Confirmed → In Progress
GunChleoc (gunchleoc) on 2017-04-22
Changed in widelands:
status: In Progress → Fix Committed
assignee: GunChleoc (gunchleoc) → nobody
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers