[Freeciv-Dev] [bug #15617] Scripting: Default script, Ruleset script, and scenario share namespace

2010-03-20 Thread pepeto

Update of bug #15617 (project freeciv):

  Status:None => Fixed  
 Open/Closed:Open => Closed 


___

Reply to this item at:

  

___
  Message posté via/par Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #15617] Scripting: Default script, Ruleset script, and scenario share namespace

2010-03-17 Thread pepeto

Update of bug #15617 (project freeciv):

 Assigned to:None => pepeto 
 Planned Release: => 2.2.1, 2.3.0   


___

Reply to this item at:

  

___
  Message posté via/par Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #15617] Scripting: Default script, Ruleset script, and scenario share namespace

2010-03-14 Thread Ulrik Sverdrup

Update of bug #15617 (project freeciv):

  Depends on: => patch #1531


___

Reply to this item at:

  

___
  Meddelandet skickades via/av Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev


[Freeciv-Dev] [bug #15617] Scripting: Default script, Ruleset script, and scenario share namespace

2010-03-14 Thread Ulrik Sverdrup

URL:
  

 Summary: Scripting: Default script, Ruleset script, and
scenario share namespace
 Project: Freeciv
Submitted by: englabenny
Submitted on: söndag 2010-03-14 den 14:07
Category: general
Severity: 3 - Normal
Priority: 1 - Later
  Status: None
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Release: 2.2
 Discussion Lock: Any
Operating System: None
 Planned Release: 

___

Details:


Scripting happens in three places:

default.lua
scripting.lua
script.code  in Scenario file

These are all evaluated inside the same lua state, so they share the same
global namespace. This is significant since event callbacks are registered by
name, then looked up in the global namespace by that name.

I suspect the following pattern to be common (default.lua):

signal.connect("hut_enter", "hut_enter_callback")

If the scenario now defines a function called 'hut_enter_callback', that
function will be called instead. However, if the scenario also connects the
same signal to the same-named function, the exact same function will be
called twice.

This namespace sharing is both a curse and a blessing: It allows non-default
rulesets (in script.lua) to override specific functions in the default
ruleset. It allows Scenarios to override specific callbacks from the
ruleset.

I propose that the default ruleset should simply use a consistent naming
scheme, so that accidental overrides are unlikely.

We change hut_enter_callback -> default_hut_enter_callback

And why not all the helper functions the same way, hut_get_mercenaries ->
default_hut_get_mercenaries


I think it would actually be possible to separate these two, we could in fact
have separate lua states for ruleset and scenario, but then we lose the
possible benefits.




___

Reply to this item at:

  

___
  Meddelandet skickades via/av Gna!
  http://gna.org/


___
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev