Implement lua functions needed for Empire scenario 3

Bug #1675179 reported by hessenfarmer
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
widelands
Fix Released
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.

Tags: campaign lua

Related branches

GunChleoc (gunchleoc)
Changed in widelands:
milestone: none → build20-rc1
status: New → Confirmed
tags: added: campaign lua
Changed in widelands:
assignee: nobody → GunChleoc (gunchleoc)
Revision history for this message
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?

Revision history for this message
GunChleoc (gunchleoc) wrote :

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

Revision history for this message
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?

Revision history for this message
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)
summary: - missing/new lua functions
+ Implement lua functions needed for Empire scenario 3
Revision history for this message
GunChleoc (gunchleoc) wrote :
Revision history for this message
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?

Revision history for this message
GunChleoc (gunchleoc) wrote :

Yes, new bug please.

Revision history for this message
kaputtnik (franku) wrote :
Revision history for this message
kaputtnik (franku) wrote :
Revision history for this message
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?

Revision history for this message
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.

Revision history for this message
kaputtnik (franku) wrote :
Revision history for this message
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.

Revision history for this message
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.

Revision history for this message
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)
Changed in widelands:
status: Confirmed → In Progress
GunChleoc (gunchleoc)
Changed in widelands:
status: In Progress → Fix Committed
assignee: GunChleoc (gunchleoc) → nobody
Revision history for this message
GunChleoc (gunchleoc) wrote :

Fixed in build20-rc1

Changed in widelands:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.